def run(self): platform_arch = platform.architecture()[0] log.info("Python architecture is %s" % platform_arch) build_type = OPTION_DEBUG and "Debug" or "Release" if OPTION_RELWITHDEBINFO: build_type = 'RelWithDebInfo' # Check env make_path = None make_generator = None if not OPTION_ONLYPACKAGE: if OPTION_MAKESPEC == "make": make_name = "make" make_generator = "Unix Makefiles" elif OPTION_MAKESPEC == "msvc": nmake_path = find_executable("nmake") if nmake_path is None or not os.path.exists(nmake_path): log.info("nmake not found. Trying to initialize the MSVC env...") init_msvc_env(platform_arch, build_type) else: log.info("nmake was found in %s" % nmake_path) if OPTION_JOM: make_name = "jom" make_generator = "NMake Makefiles JOM" else: make_name = "nmake" make_generator = "NMake Makefiles" elif OPTION_MAKESPEC == "mingw": make_name = "mingw32-make" make_generator = "MinGW Makefiles" else: raise DistutilsSetupError( "Invalid option --make-spec.") make_path = find_executable(make_name) if make_path is None or not os.path.exists(make_path): raise DistutilsSetupError( "You need the program \"%s\" on your system path to compile PySide2." \ % make_name) if OPTION_CMAKE is None or not os.path.exists(OPTION_CMAKE): raise DistutilsSetupError( "Failed to find cmake." " Please specify the path to cmake with --cmake parameter.") if OPTION_QMAKE is None or not os.path.exists(OPTION_QMAKE): raise DistutilsSetupError( "Failed to find qmake." " Please specify the path to qmake with --qmake parameter.") # Prepare parameters py_executable = sys.executable py_version = "%s.%s" % (sys.version_info[0], sys.version_info[1]) 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: py_scripts_dir = os.path.join(py_prefix, "bin") if py_libdir is None or not os.path.exists(py_libdir): if sys.platform == "win32": 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" if sys.platform == "win32": if OPTION_MAKESPEC == "mingw": py_library = os.path.join(py_libdir, "libpython%s%s.a" % \ (py_version.replace(".", ""), dbgPostfix)) else: py_library = os.path.join(py_libdir, "python%s%s.lib" % \ (py_version.replace(".", ""), dbgPostfix)) else: lib_exts = ['.so'] if sys.platform == 'darwin': lib_exts.append('.dylib') if sys.version_info[0] > 2: lib_suff = getattr(sys, 'abiflags', None) else: # Python 2 lib_suff = '' lib_exts.append('.so.1') lib_exts.append('.a') # static library as last gasp if sys.version_info[0] == 2 and dbgPostfix: # For Python2 add a duplicate set of extensions combined with # the dbgPostfix, so we test for both the debug version of # the lib and the normal one. This allows a debug PySide2 to # be built with a non-debug Python. lib_exts = [dbgPostfix + e for e in lib_exts] + lib_exts libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(py_libdir, lib_name) if os.path.exists(py_library): break libs_tried.append(py_library) else: py_multiarch = get_config_var("MULTIARCH") if py_multiarch: try_py_libdir = os.path.join(py_libdir, py_multiarch) libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(try_py_libdir, lib_name) if os.path.exists(py_library): py_libdir = try_py_libdir break libs_tried.append(py_library) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) if py_library.endswith('.a'): # Python was compiled as a static library log.error("Failed to locate a dynamic Python library, using %s" % py_library) qtinfo = QtInfo(OPTION_QMAKE) qt_dir = os.path.dirname(OPTION_QMAKE) qt_version = qtinfo.version if not qt_version: log.error("Failed to query the Qt version with qmake %s" % qtinfo.qmake_path) sys.exit(1) # Update the PATH environment variable update_env_path([py_scripts_dir, qt_dir]) build_name = "py%s-qt%s-%s-%s" % \ (py_version, qt_version, platform.architecture()[0], build_type.lower()) script_dir = os.getcwd() sources_dir = os.path.join(script_dir, "sources") build_dir = os.path.join(script_dir, "pyside_build", "%s" % build_name) install_dir = os.path.join(script_dir, "pyside_install", "%s" % build_name) # Try to ensure that tools built by this script (such as shiboken2) # are found before any that may already be installed on the system. update_env_path([os.path.join(install_dir, 'bin')]) # 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 self.script_dir = script_dir self.sources_dir = sources_dir self.build_dir = build_dir self.install_dir = install_dir self.qmake_path = OPTION_QMAKE self.py_executable = py_executable self.py_include_dir = py_include_dir self.py_library = py_library self.py_version = py_version self.build_type = build_type self.qtinfo = qtinfo self.site_packages_dir = get_python_lib(1, 0, prefix=install_dir) self.build_tests = OPTION_BUILDTESTS log.info("=" * 30) log.info("Package version: %s" % __version__) log.info("Build type: %s" % self.build_type) log.info("Build tests: %s" % self.build_tests) log.info("-" * 3) log.info("Make path: %s" % self.make_path) log.info("Make generator: %s" % self.make_generator) log.info("Make jobs: %s" % OPTION_JOBS) log.info("-" * 3) log.info("Script directory: %s" % self.script_dir) log.info("Sources directory: %s" % self.sources_dir) log.info("Build directory: %s" % self.build_dir) log.info("Install directory: %s" % self.install_dir) log.info("Python site-packages install directory: %s" % self.site_packages_dir) log.info("-" * 3) log.info("Python executable: %s" % self.py_executable) log.info("Python includes: %s" % self.py_include_dir) log.info("Python library: %s" % self.py_library) log.info("Python prefix: %s" % py_prefix) log.info("Python scripts: %s" % py_scripts_dir) log.info("-" * 3) log.info("Qt qmake: %s" % self.qmake_path) log.info("Qt version: %s" % qtinfo.version) log.info("Qt bins: %s" % qtinfo.bins_dir) log.info("Qt docs: %s" % qtinfo.docs_dir) log.info("Qt plugins: %s" % qtinfo.plugins_dir) log.info("-" * 3) log.info("OpenSSL libs: %s" % OPTION_OPENSSL) log.info("=" * 30) # Prepare folders if not os.path.exists(self.sources_dir): log.info("Creating sources folder %s..." % self.sources_dir) os.makedirs(self.sources_dir) if not os.path.exists(self.build_dir): log.info("Creating build folder %s..." % self.build_dir) os.makedirs(self.build_dir) if not os.path.exists(self.install_dir): log.info("Creating install folder %s..." % self.install_dir) os.makedirs(self.install_dir) if not OPTION_ONLYPACKAGE: # Build extensions for ext in ['shiboken2', 'pyside2', 'pyside2-tools']: self.build_extension(ext) # Build patchelf if needed self.build_patchelf() # Prepare packages self.prepare_packages() # Build packages _build.run(self)
def run(self): platform_arch = platform.architecture()[0] log.info("Python architecture is %s" % platform_arch) # Try to init the MSVC environment if sys.platform == "win32" and OPTION_MAKESPEC == "msvc": init_msvc_env(OPTION_MSVCVERSION, platform_arch, log) # Check env make_path = None make_generator = None if not OPTION_ONLYPACKAGE: if OPTION_MAKESPEC == "make": make_name = "make" make_generator = "Unix Makefiles" elif OPTION_MAKESPEC == "msvc": make_name = "nmake" make_generator = "NMake Makefiles" elif OPTION_MAKESPEC == "mingw": make_name = "mingw32-make" make_generator = "MinGW Makefiles" else: raise DistutilsSetupError( "Invalid option --make-spec.") make_path = find_executable(make_name) if make_path is None or not os.path.exists(make_path): raise DistutilsSetupError( "You need the program \"%s\" on your system path to compile PySide." \ % make_name) if OPTION_CMAKE is None or not os.path.exists(OPTION_CMAKE): raise DistutilsSetupError( "Failed to find cmake." " Please specify the path to cmake with --cmake parameter.") if OPTION_QMAKE is None or not os.path.exists(OPTION_QMAKE): raise DistutilsSetupError( "Failed to find qmake." " Please specify the path to qmake with --qmake parameter.") # Prepare parameters build_type = OPTION_DEBUG and "Debug" or "Release" if OPTION_RELWITHDEBINFO: build_type = 'RelWithDebInfo' py_executable = sys.executable py_version = "%s.%s" % (sys.version_info[0], sys.version_info[1]) py_include_dir = get_config_var("INCLUDEPY") py_libdir = get_config_var("LIBDIR") py_prefix = get_config_var("prefix") if sys.platform == "win32": py_scripts_dir = os.path.join(py_prefix, "Scripts") else: py_scripts_dir = os.path.join(py_prefix, "bin") if py_libdir is None or not os.path.exists(py_libdir): if sys.platform == "win32": py_libdir = os.path.join(py_prefix, "libs") else: py_libdir = os.path.join(py_prefix, "lib") dbgPostfix = "" if build_type == "Debug": dbgPostfix = "_d" if sys.platform == "win32": if OPTION_MAKESPEC == "mingw": py_library = os.path.join(py_libdir, "libpython%s%s.a" % \ (py_version.replace(".", ""), dbgPostfix)) else: py_library = os.path.join(py_libdir, "python%s%s.lib" % \ (py_version.replace(".", ""), dbgPostfix)) else: lib_exts = ['.so'] if sys.platform == 'darwin': lib_exts.append('.dylib') if sys.version_info[0] > 2: lib_suff = getattr(sys, 'abiflags', None) else: # Python 2 lib_suff = dbgPostfix lib_exts.append('.so.1') lib_exts.append('.a') # static library as last gasp libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(py_libdir, lib_name) if os.path.exists(py_library): break libs_tried.append(py_library) else: py_multiarch = get_config_var("MULTIARCH") if py_multiarch: try_py_libdir = os.path.join(py_libdir, py_multiarch) libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(try_py_libdir, lib_name) if os.path.exists(py_library): py_libdir = try_py_libdir break libs_tried.append(py_library) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) if py_library.endswith('.a'): # Python was compiled as a static library log.error("Failed to locate a dynamic Python library, using %s" % py_library) qtinfo = QtInfo(OPTION_QMAKE) qt_dir = os.path.dirname(OPTION_QMAKE) qt_version = qtinfo.version if not qt_version: log.error("Failed to query the Qt version with qmake %s" % qtinfo.qmake_path) sys.exit(1) # Update the PATH environment variable update_env_path([py_scripts_dir, qt_dir], log) build_name = "py%s-qt%s-%s-%s" % \ (py_version, qt_version, platform.architecture()[0], build_type.lower()) script_dir = os.getcwd() sources_dir = os.path.join(script_dir, "sources") 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)) self.make_path = make_path self.make_generator = make_generator self.debug = OPTION_DEBUG self.script_dir = script_dir self.sources_dir = sources_dir self.build_dir = build_dir self.install_dir = install_dir self.qmake_path = OPTION_QMAKE self.py_executable = py_executable self.py_include_dir = py_include_dir self.py_library = py_library self.py_version = py_version self.build_type = build_type self.qtinfo = qtinfo log.info("=" * 30) log.info("Package version: %s" % __version__) log.info("Build type: %s" % self.build_type) log.info("-" * 3) log.info("Make path: %s" % self.make_path) log.info("Make generator: %s" % self.make_generator) log.info("-" * 3) log.info("Script directory: %s" % self.script_dir) log.info("Sources directory: %s" % self.sources_dir) log.info("Build directory: %s" % self.build_dir) log.info("Install directory: %s" % self.install_dir) log.info("-" * 3) log.info("Python executable: %s" % self.py_executable) log.info("Python includes: %s" % self.py_include_dir) log.info("Python library: %s" % self.py_library) log.info("Python prefix: %s" % py_prefix) log.info("Python scripts: %s" % py_scripts_dir) log.info("-" * 3) log.info("Qt qmake: %s" % self.qmake_path) log.info("Qt version: %s" % qtinfo.version) log.info("Qt bins: %s" % qtinfo.bins_dir) log.info("Qt plugins: %s" % qtinfo.plugins_dir) log.info("-" * 3) log.info("OpenSSL libs: %s" % OPTION_OPENSSL) log.info("=" * 30) # Prepare folders if not os.path.exists(self.sources_dir): log.info("Creating sources folder %s..." % self.sources_dir) os.makedirs(self.sources_dir) if not os.path.exists(self.build_dir): log.info("Creating build folder %s..." % self.build_dir) os.makedirs(self.build_dir) if not os.path.exists(self.install_dir): log.info("Creating install folder %s..." % self.install_dir) os.makedirs(self.install_dir) if not OPTION_ONLYPACKAGE: # Build extensions for ext in ['shiboken', 'pyside', 'pyside-tools']: self.build_extension(ext) # Build patchelf if needed self.build_patchelf() # Prepare packages self.prepare_packages() # Build packages _build.run(self)
def run(self): platform_arch = platform.architecture()[0] log.info("Python architecture is %s" % platform_arch) build_type = OPTION_DEBUG and "Debug" or "Release" if OPTION_RELWITHDEBINFO: build_type = 'RelWithDebInfo' # Check env make_path = None make_generator = None if not OPTION_ONLYPACKAGE: if OPTION_MAKESPEC == "make": make_name = "make" make_generator = "Unix Makefiles" elif OPTION_MAKESPEC == "msvc": nmake_path = find_executable("nmake") if nmake_path is None or not os.path.exists(nmake_path): log.info( "nmake not found. Trying to initialize the MSVC env..." ) init_msvc_env(platform_arch, build_type) else: log.info("nmake was found in %s" % nmake_path) if OPTION_JOM: make_name = "jom" make_generator = "NMake Makefiles JOM" else: make_name = "nmake" make_generator = "NMake Makefiles" elif OPTION_MAKESPEC == "mingw": make_name = "mingw32-make" make_generator = "MinGW Makefiles" else: raise DistutilsSetupError("Invalid option --make-spec.") make_path = find_executable(make_name) if make_path is None or not os.path.exists(make_path): raise DistutilsSetupError( "You need the program \"%s\" on your system path to compile PySide." \ % make_name) if OPTION_CMAKE is None or not os.path.exists(OPTION_CMAKE): raise DistutilsSetupError( "Failed to find cmake." " Please specify the path to cmake with --cmake parameter." ) if OPTION_QMAKE is None or not os.path.exists(OPTION_QMAKE): raise DistutilsSetupError( "Failed to find qmake." " Please specify the path to qmake with --qmake parameter.") # Prepare parameters py_executable = sys.executable py_version = "%s.%s" % (sys.version_info[0], sys.version_info[1]) 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: py_scripts_dir = os.path.join(py_prefix, "bin") if py_libdir is None or not os.path.exists(py_libdir): if sys.platform == "win32": 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" if sys.platform == "win32": if OPTION_MAKESPEC == "mingw": py_library = os.path.join(py_libdir, "libpython%s%s.a" % \ (py_version.replace(".", ""), dbgPostfix)) else: py_library = os.path.join(py_libdir, "python%s%s.lib" % \ (py_version.replace(".", ""), dbgPostfix)) else: lib_exts = ['.so'] if sys.platform == 'darwin': lib_exts.append('.dylib') if sys.version_info[0] > 2: lib_suff = getattr(sys, 'abiflags', None) else: # Python 2 lib_suff = '' lib_exts.append('.so.1') lib_exts.append('.a') # static library as last gasp if sys.version_info[0] == 2 and dbgPostfix: # For Python2 add a duplicate set of extensions combined with # the dbgPostfix, so we test for both the debug version of # the lib and the normal one. This allows a debug PySide to # be built with a non-debug Python. lib_exts = [dbgPostfix + e for e in lib_exts] + lib_exts libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(py_libdir, lib_name) if os.path.exists(py_library): break libs_tried.append(py_library) else: py_multiarch = get_config_var("MULTIARCH") if py_multiarch: try_py_libdir = os.path.join(py_libdir, py_multiarch) libs_tried = [] for lib_ext in lib_exts: lib_name = "libpython%s%s%s" % (py_version, lib_suff, lib_ext) py_library = os.path.join(try_py_libdir, lib_name) if os.path.exists(py_library): py_libdir = try_py_libdir break libs_tried.append(py_library) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) else: raise DistutilsSetupError( "Failed to locate the Python library with %s" % ', '.join(libs_tried)) if py_library.endswith('.a'): # Python was compiled as a static library log.error( "Failed to locate a dynamic Python library, using %s" % py_library) qtinfo = QtInfo(OPTION_QMAKE) qt_dir = os.path.dirname(OPTION_QMAKE) qt_version = qtinfo.version if not qt_version: log.error("Failed to query the Qt version with qmake %s" % qtinfo.qmake_path) sys.exit(1) # Update the PATH environment variable update_env_path([py_scripts_dir, qt_dir]) build_name = "py%s-qt%s-%s-%s" % \ (py_version, qt_version, platform.architecture()[0], build_type.lower()) script_dir = os.getcwd() sources_dir = os.path.join(script_dir, "sources") build_dir = os.path.join(script_dir, "pyside_build", "%s" % build_name) install_dir = os.path.join(script_dir, "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')]) # 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 self.script_dir = script_dir self.sources_dir = sources_dir self.build_dir = build_dir self.install_dir = install_dir self.qmake_path = OPTION_QMAKE self.py_executable = py_executable self.py_include_dir = py_include_dir self.py_library = py_library self.py_version = py_version self.build_type = build_type self.qtinfo = qtinfo self.site_packages_dir = get_python_lib(1, 0, prefix=install_dir) self.build_tests = OPTION_BUILDTESTS log.info("=" * 30) log.info("Package version: %s" % __version__) log.info("Build type: %s" % self.build_type) log.info("Build tests: %s" % self.build_tests) log.info("-" * 3) log.info("Make path: %s" % self.make_path) log.info("Make generator: %s" % self.make_generator) log.info("Make jobs: %s" % OPTION_JOBS) log.info("-" * 3) log.info("Script directory: %s" % self.script_dir) log.info("Sources directory: %s" % self.sources_dir) log.info("Build directory: %s" % self.build_dir) log.info("Install directory: %s" % self.install_dir) log.info("Python site-packages install directory: %s" % self.site_packages_dir) log.info("-" * 3) log.info("Python executable: %s" % self.py_executable) log.info("Python includes: %s" % self.py_include_dir) log.info("Python library: %s" % self.py_library) log.info("Python prefix: %s" % py_prefix) log.info("Python scripts: %s" % py_scripts_dir) log.info("-" * 3) log.info("Qt qmake: %s" % self.qmake_path) log.info("Qt version: %s" % qtinfo.version) log.info("Qt bins: %s" % qtinfo.bins_dir) log.info("Qt plugins: %s" % qtinfo.plugins_dir) log.info("-" * 3) log.info("OpenSSL libs: %s" % OPTION_OPENSSL) log.info("=" * 30) # Prepare folders if not os.path.exists(self.sources_dir): log.info("Creating sources folder %s..." % self.sources_dir) os.makedirs(self.sources_dir) if not os.path.exists(self.build_dir): log.info("Creating build folder %s..." % self.build_dir) os.makedirs(self.build_dir) if not os.path.exists(self.install_dir): log.info("Creating install folder %s..." % self.install_dir) os.makedirs(self.install_dir) if not OPTION_ONLYPACKAGE: # Build extensions for ext in ['shiboken', 'pyside', 'pyside-tools']: self.build_extension(ext) # Build patchelf if needed self.build_patchelf() # Prepare packages self.prepare_packages() # Build packages _build.run(self)