aboutsummaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
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 cc7db352a..5f5235da3 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 = [