# Configures and builds in directory ./build
# Creates wheel in ./dist
#
+# Note: takes an *optional* environment variable VERSION_SUFFIX. If set, this
+# suffix will be appended to the pypi package version.
+# Example:
+# VERSION_SUFFIX=rc1 python3 ./src/api/python/wheels/build_wheel.py bdist_wheel
+# would create versions X.Y.Zrc1
+#
+# The suffix should start with a letter, and end with a number
##
import os
import re
import sys
import platform
+import string
import subprocess
import multiprocessing
import shutil
from skbuild.cmaker import CMaker
from distutils.version import LooseVersion
-WORKING_DIR="build"
+WORKING_DIR = "build"
+
def get_project_src_path():
# expecting this script to be in src/api/python/wheels
project_src_path = get_project_src_path()
# read CMakeLists.txt to get version number
- version = dict()
- str_pattern = 'set\(CVC5_(?P<component>MAJOR|MINOR|RELEASE)\s*(?P<version>\d+)\)'
+ version = ''
+ str_pattern = 'set\(CVC5_LAST_RELEASE\s*"([^"]+)"\)'
pattern = re.compile(str_pattern)
- with open(os.path.join(project_src_path, 'CMakeLists.txt'), 'r') as f:
- for line in f:
- line = line.strip()
- m = pattern.search(line)
- if m:
- gd = m.groupdict()
- version[gd['component']] = gd['version']
- if len(version) == 3:
- break
-
- assert len(version) == 3, 'Expecting MAJOR, MINOR and RELEASE'
- return version['MAJOR'], version['MINOR'], version['RELEASE']
+ with open(os.path.join(project_src_path, 'cmake', 'version-base.cmake'), 'r') as f:
+ m = pattern.search(f.read())
+ if m:
+ version = m.group(1)
+ return version
+ else:
+ raise Exception('Could not find version')
class CMakeExtension(Extension):
# configure with the working directory python-build-wheel
args = ['--python-bindings',
'--auto-download',
- '--lib-only',
'--name='+WORKING_DIR]
# find correct Python include directory and library
# works even for nonstandard Python installations
# (e.g., on pypa/manylinux)
- args.append('-DPYTHON_VERSION_STRING:STRING=' + \
+ args.append('-DPYTHON_VERSION_STRING:STRING=' +
sys.version.split(' ')[0])
python_version = CMaker.get_python_version()
- args.append('-DPYTHON_INCLUDE_DIR:PATH=' + \
+ args.append('-DPYTHON_INCLUDE_DIR:PATH=' +
CMaker.get_python_include_dir(python_version))
- args.append('-DPYTHON_LIBRARY:FILEPATH=' + \
+ args.append('-DPYTHON_LIBRARY:FILEPATH=' +
CMaker.get_python_library(python_version))
config_filename = os.path.join(project_src_path, "configure.sh")
shutil.copytree(pycvc5_module, dst_name)
+version_suffix = os.getenv('VERSION_SUFFIX', '')
+if len(version_suffix) > 0:
+ assert all(c in string.ascii_letters + string.digits for c in version_suffix)
+ assert version_suffix[0] in string.ascii_letters
+ assert version_suffix[-1] in string.ascii_digits
+ print("Setting version suffix to", version_suffix)
+
+
setup(
name='pycvc5',
- version='.'.join(get_cvc5_version()),
+ version=get_cvc5_version() + version_suffix,
long_description='Python bindings for cvc5',
url='https://github.com/cvc5/cvc5',
license='BSD-3-Clause',
cmdclass=dict(build_ext=CMakeBuild),
tests_require=['pytest']
)
-