aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-07-20 18:54:05 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-10-12 14:45:35 +0000
commit43fe3494a9d902034896e3afa7b5158c77163be0 (patch)
tree07bbd20b8bd322fdf062b87dfade1e1e74d80433 /setup.py
parentc6c9f057cddc0e0b885a648489264538eba0a158 (diff)
Allow building shiboken2 and PySide2 as separate wheels
Actually this creates 3 wheel packages: - shiboken2 (the python module and libshiboken shared library) - shiboken2-generator (contains the generator executable, libclang and dependent Qt libraries) - PySide2 (the PySide2 modules and Qt shared libraries, and tools like rcc, uic) Calling the setup.py script will not do the actual build now (in the sense of calling CMake, make, etc.). Instead it will spawn new processes (via subprocess.call) calling the same setup.py script, but with different arguments. These "sub-invocations" will do the actual building. Thus, the "top-level invocation" will decide which packages to build and delegate that to the "sub-invocations" of setup.py. A new optional command line argument is introduced called "--build-type" which defaults to "all", and can also be set to "shiboken2", "shiboken2-generator" and "pyside2". A user can choose which packages to build using this option. The "top-level invocation" uses this option to decide how many "sub-invocations" to execute. A new command line argument called "--internal-build-type" takes the same values as the one above. It defines which package will actually be built in the new spawned "sub-invocation" process. The "top-level invocation" sets this automatically for each "sub-invocation" depending on the value of "--build-type". This option is also useful for developers that may want to debug the python building code in the "sub-invocation". Developers can set this manually via the command line, and thus avoid the process spawning indirection. A new class Config is introduced to facilitate storage of the various state needed for building a single package. A new class SetupRunner is introduced that takes care of the "--build-type" and "--internal-build-type" argument handling and delegation of "sub-invocations". A new class Options is introduced to 'hopefully', in the future, streamline the mess of option handling that we currently have. setup.py now is now simplified to mostly just call SetupRunner.run_setup(). Certain refactorings were done to facilitate further clean-up of the build code, the current code is definitely not the end all be all. Various other changes that were needed to implement the wheel separation: - a new cmake_helpers directory is added to share common cmake code between packages. - the custom popenasync.py file is removed in favor of using subprocess.call in as many places as possible, and thus avoid 10 different functions for process creation. - Manifest.in is removed, because copying to the setuptools build dir is now done directly by prepare_packages functions. - because prepare_packages copies directly to the setuptools build dir, avoiding the pyside_package dir, we do less copying of big Qt files now. - versioning of PySide2 and shiboken2 packages is now separate. shiboken2 and shiboken2-generator share the same versions for now though. - shiboken2 is now listed as a required package for PySide2, to facilitate pip requirements.txt dependencies. - coin_build_instructions currently needs to install an unreleased version of wheel, due to a bug that breaks installation of generated wheel files. - added separate command line options to pyside2_config.py for shiboken2-module and shiboken2-generator. - adapted samplebinding and scriptableapplication projects due to shiboken being a separate package. - adapted pyside2-tool and shiboken2-tool python scripts for setup tools entry points. - made some optimizations not to invoke cmake for shiboken2-generator when doing a top-level "all" build. - fixed unnecessary rpaths not to be included on Linux (mainly the Qt rpaths). Task-nubmer: PYSIDE-749 Change-Id: I0336043955624c1d12ed254802c442608cced5fb Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py115
1 files changed, 39 insertions, 76 deletions
diff --git a/setup.py b/setup.py
index c7e7e986..d27ca088 100644
--- a/setup.py
+++ b/setup.py
@@ -42,12 +42,18 @@ from __future__ import print_function
"""
This is a distutils setup-script for the Qt for Python project
-To build PySide2 simply execute:
+To build both shiboken2 and PySide2 simply execute:
python setup.py build
or
python setup.py install
to build and install into your current Python installation.
+The same setup.py script is used to build all the components of the
+project:
+ - shiboken2 (the supporting Python module)
+ - shiboken2-generator (the bindings generation executable)
+ - PySide2
+ - pyside2-tools
Optionally, one can specify the location of qmake and cmake if it is
not on the current PATH with:
@@ -56,6 +62,23 @@ and
--cmake=/path/to/bin/cmake
respectively.
+By default, all of the above is built when no special options are
+passed to the script. You can use the --build-type parameter to specify
+which things should be built:
+ --build-type=shiboken2 - build / package only the python module
+ --build-type=shiboken2-generator - build / package the generator
+ executable
+ --build-type=pyside2 - build / package the PySide2 bindings and
+ and pyside2-tools
+ --build-type=all - the implicit default to build all of the above
+
+
+When building PySide2, optionally, one can specify the location of the
+shiboken2 cmake config path if it is not on the current PATH with:
+ --shiboken-config-dir=/path/to/shiboken/cmake/config/dir
+This is useful if you did a cmake installation of shiboken2 into
+a custom location.
+
For Windows, if OpenSSL support is required, it's necessary to specify
the directory path that contains the OpenSSL shared libraries
"libeay32.dll" and "ssleay32.dll", for example:
@@ -79,7 +102,7 @@ not specified.
You can use the option `--only-package` if you want to create more
binary packages (bdist_wheel, bdist_egg, ...) without rebuilding the
-entire PySide2 every time:
+entire project every time:
e.g.:
@@ -89,7 +112,7 @@ e.g.:
--cmake=c:\tools\cmake\bin\cmake.exe
--openssl=c:\libs\OpenSSL32bit\bin
-* Then, we create a bdist_egg reusing PySide2 build with option
+* Then, we create a bdist_egg reusing the PySide2 build with option
`--only-package`:
python setup.py bdist_egg --only-package
@@ -110,7 +133,7 @@ new environment variable called PYSIDE_DISABLE_INTERNAL_QT_CONF is
introduced.
You should assign the integer "1" to disable the internal `qt.conf`,
-or "0" (or leave empty) to keep usining the internal `qt.conf` file.
+or "0" (or leave empty) to keep using the internal `qt.conf` file.
DEVELOPMENT OPTIONS:
@@ -230,78 +253,18 @@ this_file = os.path.abspath(this_file)
if os.path.dirname(this_file):
os.chdir(os.path.dirname(this_file))
-from build_scripts.main import get_package_version, get_setuptools_extension_modules
-from build_scripts.main import pyside_package_dir_name
-from build_scripts.main import cmd_class_dict
-from build_scripts.main import README, CHANGES
-from setuptools import setup, Extension
+# Save the original command line arguments to pass them on to the setup
+# mechanism.
+original_argv = list(sys.argv)
-# The __version__ variable is just for PEP compliancy, and shouldn't be
-# used as a value source.
+from build_scripts.main import get_package_version, check_allowed_python_version
+from build_scripts.setup_runner import SetupRunner
+
+# The __version__ variable is just for PEP compliance, and shouldn't be
+# used as a value source. Use get_package_version() instead.
__version__ = get_package_version()
-extension_modules = get_setuptools_extension_modules()
-
-setup(
- name = "PySide2",
- version = get_package_version(),
- description = ("Python bindings for the Qt cross-platform application and "
- "UI framework"),
- long_description = README + "\n\n" + CHANGES,
- long_description_content_type = 'text/markdown',
- classifiers = [
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Console',
- 'Environment :: MacOS X',
- 'Environment :: X11 Applications :: Qt',
- 'Environment :: Win32 (MS Windows)',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
- 'Operating System :: MacOS :: MacOS X',
- 'Operating System :: POSIX',
- 'Operating System :: POSIX :: Linux',
- 'Operating System :: Microsoft',
- 'Operating System :: Microsoft :: Windows',
- 'Programming Language :: C++',
- 'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Programming Language :: Python :: 3.7',
- 'Topic :: Database',
- 'Topic :: Software Development',
- 'Topic :: Software Development :: Code Generators',
- 'Topic :: Software Development :: Libraries :: Application Frameworks',
- 'Topic :: Software Development :: User Interfaces',
- 'Topic :: Software Development :: Widget Sets',
- ],
- keywords = 'Qt',
- author = 'Qt for Python Team',
- author_email = 'pyside@qt-project.org',
- url = 'https://www.pyside.org',
- download_url = 'https://download.qt.io/official_releases/QtForPython/',
- license = 'LGPL',
- packages = ['PySide2', 'pyside2uic',
- 'pyside2uic.Compiler',
- 'pyside2uic.port_v{}'.format(sys.version_info[0]) ],
- package_dir = {'': pyside_package_dir_name},
- include_package_data = True,
- zip_safe = False,
- entry_points = {
- 'console_scripts': [
- 'pyside2-uic = PySide2.scripts.uic:main',
- 'pyside2-rcc = PySide2.scripts.pyside_tool:main',
- 'pyside2-lupdate = PySide2.scripts.pyside_tool:main',
- 'shiboken2 = PySide2.scripts.pyside_tool:main',
- ]
- },
- cmdclass = cmd_class_dict,
- # Add a bogus extension module (will never be built here since we
- # are overriding the build command to do it using cmake) so things
- # like bdist_egg will know that there are extension modules and
- # will name the dist with the full platform info.
- ext_modules = extension_modules,
- ext_package = 'PySide2',
-)
+check_allowed_python_version()
+
+setup_runner = SetupRunner(original_argv)
+setup_runner.run_setup()