aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-09-09 13:49:49 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-09-12 13:56:40 +0000
commit43e0286f62e851f2b396dcc935941428f8ede181 (patch)
tree13675c2c5ed92d5fe0447e117a8b9e09c4c81cf1 /setup.py
parent6eaffafe45e6c6ab495d4617069af6b36c7dcd50 (diff)
Restructure setup.py
Move all code that was unconditionally executed at startup into a subroutine prepareBuild() and execute that from the build command class. Overwrite the Distutils'_install to be extended. This makes the standard --help options of DistUtils work as expected and causes the script to require a command argument instead of starting unconditionally. Change-Id: I0bf1bfc4ba0e15662122733b04e468f1838e4ae8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py43
1 files changed, 27 insertions, 16 deletions
diff --git a/setup.py b/setup.py
index 7c4f2ed60..537613a59 100644
--- a/setup.py
+++ b/setup.py
@@ -286,7 +286,7 @@ if OPTION_NOEXAMPLES:
# Initialize, pull and checkout submodules
-if os.path.isdir(".git") and not OPTION_IGNOREGIT and not OPTION_ONLYPACKAGE and not OPTION_REUSE_BUILD:
+def prepareSubModules():
print("Initializing submodules for PySide2 version %s" % __version__)
git_update_cmd = ["git", "submodule", "update", "--init"]
if run_process(git_update_cmd) != 0:
@@ -309,21 +309,30 @@ if os.path.isdir(".git") and not OPTION_IGNOREGIT and not OPTION_ONLYPACKAGE and
raise DistutilsSetupError("Failed to initialize the git submodule %s" % module_name)
os.chdir(script_dir)
-# Clean up temp and package folders
-for n in ["pyside_package", "build", "PySide2-%s" % __version__]:
- d = os.path.join(script_dir, n)
- if os.path.isdir(d):
- print("Removing %s" % d)
- try:
- rmtree(d)
- except Exception as e:
- print('***** problem removing "{}"'.format(d))
- print('ignored error: {}'.format(e))
-
-# Prepare package folders
-for pkg in ["pyside_package/PySide2", "pyside_package/pyside2uic"]:
- pkg_dir = os.path.join(script_dir, pkg)
- os.makedirs(pkg_dir)
+def prepareBuild():
+ if os.path.isdir(".git") and not OPTION_IGNOREGIT and not OPTION_ONLYPACKAGE and not OPTION_REUSE_BUILD:
+ prepareSubModules()
+ # Clean up temp and package folders
+ for n in ["pyside_package", "build", "PySide2-%s" % __version__]:
+ d = os.path.join(script_dir, n)
+ if os.path.isdir(d):
+ print("Removing %s" % d)
+ try:
+ rmtree(d)
+ except Exception as e:
+ print('***** problem removing "{}"'.format(d))
+ print('ignored error: {}'.format(e))
+ # Prepare package folders
+ for pkg in ["pyside_package/PySide2", "pyside_package/pyside2uic"]:
+ pkg_dir = os.path.join(script_dir, pkg)
+ os.makedirs(pkg_dir)
+
+class pyside_install(_install):
+ def _init(self, *args, **kwargs):
+ _install.__init__(self, *args, **kwargs)
+
+ def run(self):
+ _install.run(self)
class pyside_develop(_develop):
@@ -374,6 +383,7 @@ class pyside_build(_build):
self.build_tests = False
def run(self):
+ prepareBuild()
platform_arch = platform.architecture()[0]
log.info("Python architecture is %s" % platform_arch)
@@ -1130,6 +1140,7 @@ setup(
'build_ext': pyside_build_ext,
'bdist_egg': pyside_bdist_egg,
'develop': pyside_develop,
+ 'install': pyside_install
},
# Add a bogus extension module (will never be built here since we are