From 60568283ea1e014d76959203cbd278b2dbe3bfc7 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 30 May 2013 19:01:10 -0700 Subject: Various additional build fixes and tweaks. - Validate py_prefix and py_include_dir - Add install_dir/bin to the PATH - Set CMAKE_PREFIX_PATH to install_dir - If QTDIR is set then use it for ALTERNATIVE_QT_INCLUDE_DIR --- setup.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 722fa81ba..a25e00eaa 100644 --- a/setup.py +++ b/setup.py @@ -310,6 +310,8 @@ class pyside_build(_build): py_include_dir = get_config_var("INCLUDEPY") py_libdir = get_config_var("LIBDIR") py_prefix = get_config_var("prefix") + if not py_prefix or not os.path.exists(py_prefix): + py_prefix = sys.prefix if sys.platform == "win32": py_scripts_dir = os.path.join(py_prefix, "Scripts") else: @@ -319,6 +321,11 @@ class pyside_build(_build): py_libdir = os.path.join(py_prefix, "libs") else: py_libdir = os.path.join(py_prefix, "lib") + if py_include_dir is None or not os.path.exists(py_include_dir): + if sys.platform == "win32": + py_include_dir = os.path.join(py_prefix, "include") + else: + py_include_dir = os.path.join(py_prefix, "include/python%s" % py_version) dbgPostfix = "" if build_type == "Debug": dbgPostfix = "_d" @@ -389,6 +396,13 @@ class pyside_build(_build): build_dir = os.path.join(script_dir, os.path.join("pyside_build", "%s" % build_name)) install_dir = os.path.join(script_dir, os.path.join("pyside_install", "%s" % build_name)) + # Try to ensure that tools built by this script (such as shiboken) + # are found before any that may already be installed on the system. + update_env_path([os.path.join(install_dir, 'bin')], log) + + # Tell cmake to look here for *.cmake files + os.environ['CMAKE_PREFIX_PATH'] = install_dir + self.make_path = make_path self.make_generator = make_generator self.debug = OPTION_DEBUG @@ -481,7 +495,7 @@ class pyside_build(_build): log.info("Deleting module build folder %s..." % module_build_dir) rmtree(module_build_dir) log.info("Creating module build folder %s..." % module_build_dir) - os.mkdir(module_build_dir) + os.makedirs(module_build_dir) os.chdir(module_build_dir) module_src_dir = os.path.join(self.sources_dir, extension) @@ -518,10 +532,15 @@ class pyside_build(_build): if sys.version_info[0] > 2: cmake_cmd.append("-DUSE_PYTHON3=ON") elif sys.platform == 'darwin': - # Work round cmake include problem - # http://neilweisenfeld.com/wp/120/building-pyside-on-the-mac - # https://groups.google.com/forum/#!msg/pyside/xciZZ4Hm2j8/CUmqfJptOwoJ - cmake_cmd.append('-DALTERNATIVE_QT_INCLUDE_DIR=/Library/Frameworks') + if 'QTDIR' in os.environ: + # If the user has QTDIR set, then use it as a prefix for an extra include path + cmake_cmd.append('-DALTERNATIVE_QT_INCLUDE_DIR={0}/include:{0}/lib'.format(os.environ['QTDIR'])) + else: + # Otherwise assume it is a standard install and add the + # Frameworks folder as a workaround for a cmake include problem + # http://neilweisenfeld.com/wp/120/building-pyside-on-the-mac + # https://groups.google.com/forum/#!msg/pyside/xciZZ4Hm2j8/CUmqfJptOwoJ + cmake_cmd.append('-DALTERNATIVE_QT_INCLUDE_DIR=/Library/Frameworks') log.info("Configuring module %s (%s)..." % (extension, module_src_dir)) if run_process(cmake_cmd, log) != 0: @@ -883,4 +902,4 @@ setup( # dist with the full platform info. #ext_modules = [Extension('QtCore', [])], ext_package = 'PySide', -) \ No newline at end of file +) -- cgit v1.2.3