aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-03-01 11:50:07 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-03-02 20:34:51 +0000
commitb57c557c8cd1012851f8a245075591dc33be425b (patch)
treed110d231b3ed3229e37b214acba6e219a9134939 /setup.py
parent648ea14719702c497d329b00cb7db7721a06402a (diff)
Implement proper package versioning
This change is inspired by / follows PEP 440 for handling version numbers and also takes into account the Qt versioning scheme. PySide2 as package name will stay as-is (not renamed to PySide5). Release versions would have the following pattern: PySide2 5.x.y (e.g. 5.6.3) Package (wheel) name would also contain the bundled Qt version, e.g.: PySide2-5.6.0-5.6.4-cp27-cp27m-macosx_10_7_intel.whl Pre-release versions would look like: PySide2 5.6.0a1, 5.6.0a2, 5.6.0b1, 5.6.0b2, 5.6.0rc1, etc. Development (snapshot) versions would look like: PySide2 5.6.0-dev123456789 (last part is timestamp of build time) All of the examples above comply with the PEP 440 rules. In the example above where the Qt version is specified as part of the wheel package name ("5.6.4"), the Qt version is not part of the package version itself, because it doesn't comply with PEP 440. But it does comply with wheel package names (PEP 427), and by that PEP's definitions, it will be the optional "build tag" part of the file name, which is preceded by the actual package version, and followed by the python version / abi tag. Implementation: This change defines two new python configuration files which will be the authoritative source for the shiboken and PySide2 libraries, as well as the final PySide2 package itself: sources/shiboken/shiboken_version.py sources/pyside2/pyside_version.py The pyside_version.py file will be the source of the final package version. The shiboken and PySide2 version should be modified in sync, when bumping the version of the package before a release. The reason for having both files instead of 1, is to make life easier for developers that might extract only shiboken from the repository. If at some point shiboken and PySide2 CMake projects get merged into one project, the duplicate version files would go away. The version files are parsed by CMake to correctly name the shared libraries (and SO versions), and they are also read by the setup.py script, to generate correct package metadata and a correct package (wheel) name. This change also removes the broken dist targets from PySide2's and shiboken's CMakelists files, which depended on some version suffix which was never set in setup.py. PEP440: https://www.python.org/dev/peps/pep-0440/ PEP427: https://www.python.org/dev/peps/pep-0427/ Change-Id: I3226460b1adf2555c8711fa2ba47c223b957cb44 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py77
1 files changed, 49 insertions, 28 deletions
diff --git a/setup.py b/setup.py
index cc7db352..5f5235da 100644
--- a/setup.py
+++ b/setup.py
@@ -125,16 +125,42 @@ OS X Minimum deployment target:
version.
"""
-# This stores the current repo branch / tag version.
-current_git_branch_version = "5.6"
+import os
+import time
+from utils import memoize, has_option, get_python_dict
+OPTION_SNAPSHOT_BUILD = has_option("snapshot-build")
+script_dir = os.getcwd()
+
+
+@memoize
+def get_package_timestamp():
+ return int(time.time())
-# This is just for PEP compliance, and shoudn't be used.
-__version__ = current_git_branch_version
+@memoize
+def get_package_version():
+ """ Returns the version string for the PySide2 package. """
+ pyside_version_py = os.path.join(script_dir, "sources", "pyside2", "pyside_version.py")
+ d = get_python_dict(pyside_version_py)
+
+ final_version = "{}.{}.{}".format(d['major_version'], d['minor_version'], d['patch_version'])
+ pre_release_version_type = d['pre_release_version_type']
+ pre_release_version = d['pre_release_version']
+ if pre_release_version and pre_release_version:
+ final_version += pre_release_version_type + pre_release_version
+
+ # Add the current timestamp to the version number, to suggest it is a development snapshot
+ # build.
+ if OPTION_SNAPSHOT_BUILD:
+ final_version += ".dev{}".format(get_package_timestamp())
+ return final_version
+
+# The __version__ variable is just for PEP compliancy, and shoudn't be used as a value source.
+__version__ = get_package_version()
# Buildable extensions.
containedModules = ['shiboken2', 'pyside2', 'pyside2-tools']
-# Git submodules.
+# Git submodules: ["submodule_name", "location_relative_to_sources_folder"]
submodules = [["pyside2-tools"],
["pyside2-examples"],
["wiki", ".."]]
@@ -147,10 +173,8 @@ except ImportError:
from ez_setup import use_setuptools
use_setuptools()
-import os
import sys
import platform
-import time
import re
import fnmatch
@@ -188,7 +212,6 @@ from utils import makefile
from utils import copyfile
from utils import copydir
from utils import run_process_output, run_process
-from utils import has_option
from utils import option_value
from utils import update_env_path
from utils import init_msvc_env
@@ -197,7 +220,6 @@ from utils import filter_match
from utils import osx_fix_rpaths_for_library
from utils import copy_icu_libs
from utils import find_files_using_glob
-from utils import memoize
from textwrap import dedent
@@ -340,7 +362,6 @@ except NameError:
this_file = os.path.abspath(this_file)
if os.path.dirname(this_file):
os.chdir(os.path.dirname(this_file))
-script_dir = os.getcwd()
if OPTION_NOEXAMPLES:
# Remove pyside2-examples from submodules so they will not be included.
@@ -359,7 +380,7 @@ def prefix():
# Initialize, pull and checkout submodules
def prepareSubModules():
- print("Initializing submodules for PySide2 version: {}".format(current_git_branch_version))
+ print("Initializing submodules for PySide2 version: {}".format(get_package_version()))
submodules_dir = os.path.join(script_dir, "sources")
# Create list of [name, desired branch, absolute path, desired branch]
@@ -490,7 +511,8 @@ if wheel_module_exists:
# Example: PySide2-5.6-5.6.4-cp27-cp27m-macosx_10_10_intel.whl
# The PySide2 version is "5.6. The built against Qt version is "5.6.4.
qt_version = get_qt_version()
- wheel_version = "{}-{}".format(current_git_branch_version, qt_version)
+ package_version = get_package_version()
+ wheel_version = "{}-{}".format(package_version, qt_version)
components = (_safer_name(self.distribution.get_name()),
wheel_version)
if self.build_number:
@@ -779,7 +801,7 @@ class pyside_build(_build):
setuptools_install_prefix = OPTION_FINAL_INSTALL_PREFIX
log.info("=" * 30)
- log.info("Package version: %s" % current_git_branch_version)
+ log.info("Package version: %s" % get_package_version())
log.info("Build type: %s" % self.build_type)
log.info("Build tests: %s" % self.build_tests)
log.info("-" * 3)
@@ -1012,6 +1034,17 @@ class pyside_build(_build):
pyside_qt_conf_prefix = '"."'
cmake_cmd.append("-DPYSIDE_QT_CONF_PREFIX=%s" % pyside_qt_conf_prefix)
+ # Pass package version to CMake, so this string can be embedded into _config.py file.
+ package_version = get_package_version()
+ cmake_cmd.append("-DPYSIDE_SETUP_PY_PACKAGE_VERSION={0}".format(package_version))
+
+ # In case if this is a snapshot build, also pass the timestamp as a separate value,
+ # because it the only version component that is actually generated by setup.py.
+ timestamp = ''
+ if OPTION_SNAPSHOT_BUILD:
+ timestamp = get_package_timestamp()
+ cmake_cmd.append("-DPYSIDE_SETUP_PY_PACKAGE_TIMESTAMP={0}".format(timestamp))
+
if extension.lower() == "shiboken2":
cmake_cmd.append("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=yes")
if sys.version_info[0] > 2:
@@ -1120,20 +1153,8 @@ class pyside_build(_build):
# Get config that contains list of built modules, and SOVERSIONs of the built libraries.
pyside_package_dir = vars['pyside_package_dir']
config_path = os.path.join(pyside_package_dir, "PySide2", "_config.py")
-
- try:
- with open(config_path) as f:
- scoped_locals = {}
- code = compile(f.read(), config_path, 'exec')
- exec(code, scoped_locals, scoped_locals)
- config = {}
- config['built_modules'] = scoped_locals['built_modules']
- config['shiboken_library_soversion'] = scoped_locals['shiboken_library_soversion']
- config['pyside_library_soversion'] = scoped_locals['pyside_library_soversion']
- return config
- except IOError as e:
- print("get_built_pyside_config: Couldn't find file: {}.".format(config_path))
- raise
+ config = get_python_dict(config_path)
+ return config
def prepare_packages_posix(self, vars):
executables = []
@@ -1718,7 +1739,7 @@ if wheel_module_exists:
setup(
name = "PySide2",
- version = current_git_branch_version,
+ version = get_package_version(),
description = ("Python bindings for the Qt cross-platform application and UI framework"),
long_description = README + "\n\n" + CHANGES,
classifiers = [