aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'build_scripts/main.py')
-rw-r--r--build_scripts/main.py114
1 files changed, 52 insertions, 62 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 8429c1fdb..84628d8e0 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -48,7 +48,7 @@ from textwrap import dedent
import time
from .config import config
from .utils import get_python_dict
-from .options import OPTION
+from .options import DistUtilsCommandMixin, OPTION
from .wheel_utils import (get_package_version, get_qt_version,
get_package_timestamp, macos_plat_name,
macos_pyside_min_deployment_target)
@@ -284,57 +284,6 @@ def check_allowed_python_version():
qt_src_dir = ''
-if OPTION["QT_VERSION"] is None:
- OPTION["QT_VERSION"] = "5"
-if OPTION["QMAKE"] is None:
- OPTION["QMAKE"] = find_executable("qmake-qt5")
-if OPTION["QMAKE"] is None:
- OPTION["QMAKE"] = find_executable("qmake")
-
-# make qtinfo.py independent of relative paths.
-if OPTION["QMAKE"] is not None and os.path.exists(OPTION["QMAKE"]):
- OPTION["QMAKE"] = os.path.abspath(OPTION["QMAKE"])
-if OPTION["CMAKE"] is not None and os.path.exists(OPTION["CMAKE"]):
- OPTION["CMAKE"] = os.path.abspath(OPTION["CMAKE"])
-
-if len(OPTION["QMAKE"]) == 0:
- print("qmake could not be found.")
- sys.exit(1)
-if not os.path.exists(OPTION["QMAKE"]):
- print("'{}' does not exist.".format(OPTION["QMAKE"]))
- sys.exit(1)
-
-if OPTION["CMAKE"] is None:
- OPTION["CMAKE"] = find_executable("cmake")
-
-if OPTION["CMAKE"] is None:
- print("cmake could not be found.")
- sys.exit(1)
-if not os.path.exists(OPTION["CMAKE"]):
- print("'{}' does not exist.".format(OPTION["CMAKE"]))
- sys.exit(1)
-
-# First element is default
-available_mkspecs = ["msvc", "mingw", "ninja"] if sys.platform == "win32" else ["make", "ninja"]
-
-if OPTION["MAKESPEC"] is None:
- OPTION["MAKESPEC"] = available_mkspecs[0]
-
-if OPTION["MAKESPEC"] not in available_mkspecs:
- print('Invalid option --make-spec "{}". Available values are {}'.format(OPTION["MAKESPEC"],
- available_mkspecs))
- sys.exit(1)
-
-if OPTION["JOBS"]:
- if sys.platform == 'win32' and OPTION["NO_JOM"]:
- print("Option --jobs can only be used with jom on Windows.")
- sys.exit(1)
- else:
- if not OPTION["JOBS"].startswith('-j'):
- OPTION["JOBS"] = '-j' + OPTION["JOBS"]
-else:
- OPTION["JOBS"] = ''
-
def is_debug_python():
return getattr(sys, "gettotalrefcount", None) is not None
@@ -357,10 +306,41 @@ def prefix():
return name
-# Single global instance of QtInfo to be used later in multiple code
-# paths.
-qtinfo = QtInfo()
-qtinfo.setup(OPTION["QMAKE"], OPTION["QT_VERSION"])
+# Initialize, pull and checkout submodules
+def prepare_sub_modules():
+ print("Initializing submodules for PySide2 version: {}".format(
+ get_package_version()))
+ submodules_dir = os.path.join(setup_script_dir, "sources")
+
+ # Create list of [name, desired branch, absolute path, desired
+ # branch] and determine whether all submodules are present
+ need_init_sub_modules = False
+
+ for m in submodules:
+ module_name = m[0]
+ module_dir = m[1] if len(m) > 1 else ''
+ module_dir = os.path.join(submodules_dir, module_dir, module_name)
+ # Check for non-empty directory (repository checked out)
+ if not os.listdir(module_dir):
+ need_init_sub_modules = True
+ break
+
+ if need_init_sub_modules:
+ git_update_cmd = ["git", "submodule", "update", "--init"]
+ if run_process(git_update_cmd) != 0:
+ m = "Failed to initialize the git submodules: update --init failed"
+ raise DistutilsSetupError(m)
+ git_pull_cmd = ["git", "submodule", "foreach", "git", "fetch", "--all"]
+ if run_process(git_pull_cmd) != 0:
+ m = "Failed to initialize the git submodules: git fetch --all failed"
+ raise DistutilsSetupError(m)
+ else:
+ print("All submodules present.")
+
+ git_update_cmd = ["git", "submodule", "update"]
+ if run_process(git_update_cmd) != 0:
+ m = "Failed to checkout the correct git submodules SHA1s."
+ raise DistutilsSetupError(m)
def prepare_build():
@@ -377,7 +357,7 @@ def prepare_build():
# locate Qt sources for the documentation
if OPTION["QT_SRC"] is None:
- install_prefix = qtinfo.prefix_dir
+ install_prefix = QtInfo().prefix_dir
if install_prefix:
global qt_src_dir
# In-source, developer build
@@ -387,9 +367,13 @@ def prepare_build():
qt_src_dir = os.path.join(os.path.dirname(install_prefix), 'Src', 'qtbase')
-class PysideInstall(_install):
+class PysideInstall(_install, DistUtilsCommandMixin):
+
+ user_options = _install.user_options + DistUtilsCommandMixin.mixin_user_options
+
def __init__(self, *args, **kwargs):
_install.__init__(self, *args, **kwargs)
+ DistUtilsCommandMixin.__init__(self)
def initialize_options(self):
_install.initialize_options(self)
@@ -408,6 +392,10 @@ class PysideInstall(_install):
# similar cases.
self.warn_dir = False
+ def finalize_options(self):
+ DistUtilsCommandMixin.mixin_finalize_options(self)
+ _install.finalize_options(self)
+
def run(self):
_install.run(self)
print('--- Install completed ({}s)'.format(elapsed()))
@@ -471,13 +459,17 @@ class PysideInstallLib(_install_lib):
return outfiles
-class PysideBuild(_build):
+class PysideBuild(_build, DistUtilsCommandMixin):
+
+ user_options = _build.user_options + DistUtilsCommandMixin.mixin_user_options
def __init__(self, *args, **kwargs):
_build.__init__(self, *args, **kwargs)
+ DistUtilsCommandMixin.__init__(self)
def finalize_options(self):
os_name_backup = os.name
+ DistUtilsCommandMixin.mixin_finalize_options(self)
if sys.platform == 'darwin':
self.plat_name = macos_plat_name()
# This is a hack to circumvent the dubious check in
@@ -498,7 +490,6 @@ class PysideBuild(_build):
_build.initialize_options(self)
self.make_path = None
self.make_generator = None
- self.debug = False
self.script_dir = None
self.sources_dir = None
self.build_dir = None
@@ -543,7 +534,7 @@ class PysideBuild(_build):
py_scripts_dir = os.path.join(py_prefix, "bin")
self.py_scripts_dir = py_scripts_dir
- self.qtinfo = qtinfo
+ self.qtinfo = QtInfo()
qt_dir = os.path.dirname(OPTION["QMAKE"])
qt_version = get_qt_version()
@@ -583,7 +574,6 @@ class PysideBuild(_build):
self.make_path = make_path
self.make_generator = make_generator
- self.debug = OPTION["DEBUG"]
self.script_dir = script_dir
self.st_build_dir = os.path.join(self.script_dir, self.build_lib)
self.sources_dir = sources_dir