aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py141
1 files changed, 111 insertions, 30 deletions
diff --git a/setup.py b/setup.py
index 8a8970c68..03e8d7800 100644
--- a/setup.py
+++ b/setup.py
@@ -38,6 +38,7 @@
#############################################################################
from __future__ import print_function
+from distutils.version import LooseVersion
"""This is a distutils setup-script for the PySide2 project
@@ -120,15 +121,16 @@ OS X Minimum deployment target:
current OS X version and on the chosen SDK version).
"""
-__version__ = "5.6"
+__version__ = "5.9"
containedModules = ['shiboken2', 'pyside2']
submodules = {
'2.0.0.dev0': [
- ["pyside2-tools", "dev"],
- ["pyside2-examples", "dev"],
- ["wiki", "master", ".."],
+ ["pyside2-tools", "dev"]
+ ],
+ '5.9': [
+ ["pyside2-tools", "5.9"]
],
'5.6': [
["pyside2-tools", "5.6"],
@@ -220,7 +222,7 @@ except ImportError:
pass
from qtinfo import QtInfo
-from utils import rmtree
+from utils import rmtree, detectClang
from utils import makefile
from utils import copyfile
from utils import copydir
@@ -292,8 +294,10 @@ OPTION_REUSE_BUILD = has_option("reuse-build")
OPTION_SKIP_CMAKE = has_option("skip-cmake")
OPTION_SKIP_MAKE_INSTALL = has_option("skip-make-install")
OPTION_SKIP_PACKAGING = has_option("skip-packaging")
+OPTION_MODULE_SUBSET = option_value("module-subset")
OPTION_RPATH_VALUES = option_value("rpath")
OPTION_QT_CONF_PREFIX = option_value("qt-conf-prefix")
+OPTION_QT_SRC = option_value("qt-src-dir")
OPTION_ICULIB = option_value("iculib-url") # Deprecated
OPTION_VERBOSE_BUILD = has_option("verbose-build")
@@ -398,12 +402,6 @@ Use --list-versions option to get list of available versions""" % OPTION_VERSION
sys.exit(1)
__version__ = OPTION_VERSION
-if OPTION_NOEXAMPLES:
- # remove pyside2-exampes from submodules so they will not be included
- for idx, item in enumerate(submodules[__version__]):
- if item[0].startswith('pyside2-examples'):
- del submodules[__version__][idx]
-
# Return a prefix suitable for the _install/_build directory
def prefix():
virtualEnvName = os.environ.get('VIRTUAL_ENV', None)
@@ -488,10 +486,15 @@ def prepareBuild():
pkg_dir = os.path.join(script_dir, pkg)
os.makedirs(pkg_dir)
# locate Qt sources for the documentation
- qmakeOutput = run_process_output([OPTION_QMAKE, '-query', 'QT_INSTALL_PREFIX/src'])
- if qmakeOutput:
- global qtSrcDir
- qtSrcDir = qmakeOutput[0].rstrip()
+ if OPTION_QT_SRC is None:
+ qmakeOutput = run_process_output([OPTION_QMAKE, '-query', 'QT_INSTALL_PREFIX'])
+ if qmakeOutput:
+ global qtSrcDir
+ installPrefix = qmakeOutput[0].rstrip()
+ if installPrefix.endswith("qtbase"): # In-source, developer build
+ qtSrcDir = installPrefix
+ else: # SDK: Use 'Src' directory
+ qtSrcDir = os.path.join(os.path.dirname(installPrefix), 'Src', 'qtbase')
def get_qt_version(computed_qtinfo = None):
if not computed_qtinfo:
@@ -820,7 +823,20 @@ class pyside_build(_build):
qt_version = get_qt_version(self.qtinfo)
# Update the PATH environment variable
- update_env_path([py_scripts_dir, qt_dir])
+ additionalPaths = [py_scripts_dir, qt_dir]
+
+ # Add Clang to path for Windows. Revisit once Clang is bundled with Qt.
+ if sys.platform == "win32" and LooseVersion(self.qtinfo.version) >= LooseVersion("5.7.0"):
+ clangDir = detectClang()
+ if clangDir[0]:
+ clangBinDir = os.path.join(clangDir[0], 'bin')
+ if not clangBinDir in os.environ.get('PATH'):
+ log.info("Adding %s as detected by %s to PATH" % (clangBinDir, clangDir[1]))
+ additionalPaths.append(clangBinDir)
+ else:
+ log.error("Failed to detect Clang by checking LLVM_INSTALL_DIR, CLANG_INSTALL_DIR, llvm-config")
+
+ update_env_path(additionalPaths)
build_name = "py%s-qt%s-%s-%s" % \
(py_version, qt_version, platform.architecture()[0], build_type.lower())
@@ -857,6 +873,9 @@ class pyside_build(_build):
if OPTION_FINAL_INSTALL_PREFIX:
setuptools_install_prefix = OPTION_FINAL_INSTALL_PREFIX
+ # Save the shiboken build dir path for clang deployment purposes.
+ self.shiboken_build_dir = os.path.join(self.build_dir, "shiboken2")
+
log.info("=" * 30)
log.info("Package version: %s" % __version__)
log.info("Build type: %s" % self.build_type)
@@ -1024,9 +1043,20 @@ class pyside_build(_build):
cmake_cmd.append("-DPYTHON_EXECUTABLE=%s" % self.py_executable)
cmake_cmd.append("-DPYTHON_INCLUDE_DIR=%s" % self.py_include_dir)
cmake_cmd.append("-DPYTHON_LIBRARY=%s" % self.py_library)
+ if OPTION_MODULE_SUBSET:
+ moduleSubSet = ''
+ for m in OPTION_MODULE_SUBSET.split(','):
+ if m.startswith('Qt'):
+ m = m[2:]
+ if moduleSubSet:
+ moduleSubSet += ';'
+ moduleSubSet += m
+ cmake_cmd.append("-DMODULES=%s" % moduleSubSet)
# Add source location for generating documentation
- if qtSrcDir:
- cmake_cmd.append("-DQT_SRC_DIR=%s" % qtSrcDir)
+ cmake_src_dir = OPTION_QT_SRC if OPTION_QT_SRC else qtSrcDir
+ cmake_cmd.append("-DQT_SRC_DIR=%s" % cmake_src_dir)
+ log.info("Qt Source dir: %s" % cmake_src_dir)
+
if self.build_type.lower() == 'debug':
cmake_cmd.append("-DPYTHON_DEBUG_LIBRARY=%s" % self.py_library)
@@ -1254,12 +1284,10 @@ class pyside_build(_build):
"{pyside_package_dir}/PySide2/support",
vars=vars)
if not OPTION_NOEXAMPLES:
- # <sources>/pyside2-examples/examples/* -> <setup>/PySide2/examples
- folder = get_extension_folder('pyside2-examples')
- copydir(
- "{sources_dir}/%s/examples" % folder,
- "{pyside_package_dir}/PySide2/examples",
- force=False, vars=vars)
+ # examples/* -> <setup>/PySide2/examples
+ copydir(os.path.join(self.script_dir, "examples"),
+ "{pyside_package_dir}/PySide2/examples",
+ force=False, vars=vars)
# Re-generate examples Qt resource files for Python 3 compatibility
if sys.version_info[0] == 3:
examples_path = "{pyside_package_dir}/PySide2/examples".format(**vars)
@@ -1275,6 +1303,9 @@ class pyside_build(_build):
else:
self.prepare_standalone_package_linux(executables, vars)
+ # Copy over clang before rpath patching.
+ self.prepare_standalone_clang(is_win=False)
+
# Update rpath to $ORIGIN
if sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
self.update_rpath("{pyside_package_dir}/PySide2".format(**vars), executables)
@@ -1512,12 +1543,10 @@ class pyside_build(_build):
"{pyside_package_dir}/PySide2/support",
vars=vars)
if not OPTION_NOEXAMPLES:
- # <sources>/pyside2-examples/examples/* -> <setup>/PySide2/examples
- folder = get_extension_folder('pyside2-examples')
- copydir(
- "{sources_dir}/%s/examples" % folder,
- "{pyside_package_dir}/PySide2/examples",
- force=False, vars=vars)
+ # examples/* -> <setup>/PySide2/examples
+ copydir(os.path.join(self.script_dir, "examples"),
+ "{pyside_package_dir}/PySide2/examples",
+ force=False, vars=vars)
# Re-generate examples Qt resource files for Python 3 compatibility
if sys.version_info[0] == 3:
examples_path = "{pyside_package_dir}/PySide2/examples".format(**vars)
@@ -1600,6 +1629,8 @@ class pyside_build(_build):
filter=["QtWebEngineProcess*.exe"],
recursive=False, vars=vars)
+ self.prepare_standalone_clang(is_win=True)
+
# pdb files for libshiboken and libpyside
if self.debug or self.build_type == 'RelWithDebInfo':
# XXX dbgPostfix gives problems - the structure in shiboken2/data should be re-written!
@@ -1619,6 +1650,56 @@ class pyside_build(_build):
filter=pdbs,
recursive=False, vars=vars)
+ def prepare_standalone_clang(self, is_win = False):
+ """ Copies the libclang library to the pyside package so that shiboken exceutable works. """
+ log.info('Finding path to the libclang shared library.')
+ cmake_cmd = [
+ OPTION_CMAKE,
+ "-L", # Lists variables
+ "-N", # Just inspects the cache (faster)
+ "--build", # Specifies the build dir
+ self.shiboken_build_dir
+ ]
+ out = run_process_output(cmake_cmd)
+ lines = [s.strip() for s in out]
+ pattern = re.compile(r"CLANG_LIBRARY:FILEPATH=(.+)$")
+
+ clang_lib_path = None
+ for line in lines:
+ match = pattern.search(line)
+ if match:
+ clang_lib_path = match.group(1)
+ break
+
+ if not clang_lib_path:
+ raise RuntimeError("Could not finding location of libclang library from CMake cache.")
+
+ if is_win:
+ # clang_lib_path points to the static import library (lib/libclang.lib), whereas we want
+ # to copy the shared library (bin/libclang.dll).
+ clang_lib_path = re.sub(r'lib/libclang.lib$', 'bin/libclang.dll', clang_lib_path)
+
+ # Path to directory containing clang.
+ clang_lib_dir = os.path.dirname(clang_lib_path)
+
+ # The name of the clang file found by CMake.
+ basename = os.path.basename(clang_lib_path)
+
+ # We want to copy the library and all the symlinks for now, thus the wildcard.
+ clang_filter = basename + "*"
+
+ # Destination is the package folder near the other extension modules.
+ destination_dir = "{}/PySide2".format(os.path.join(self.script_dir, 'pyside_package'))
+ if os.path.exists(clang_lib_path):
+ log.info('Copying libclang shared library to the pyside package.')
+
+ copydir(clang_lib_dir, destination_dir,
+ filter=[clang_filter],
+ recursive=False)
+ else:
+ raise RuntimeError("Error copying libclang library "
+ "from {} to {}. ".format(clang_lib_path, destination_dir))
+
def update_rpath(self, package_path, executables):
if sys.platform.startswith('linux'):
pyside_libs = [lib for lib in os.listdir(package_path) if filter_match(