Skip to content

Commit

Permalink
hopefully tag wheels correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmot committed Sep 2, 2024
1 parent 32010e2 commit 3b57ba4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scripts/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ stages:
# - script: cd $(Agent.TempDirectory); mkdir musl-bin; cd musl-bin; unzip ../*-linux.zip
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
- script: python3 -m pip install --user -U setuptools wheel
- script: python3 -m pip install --user -U setuptools
- script: cd src/api/python; python3 setup.py sdist
# take a look at this PREMIUM HACK I came up with to get around the fact that the azure variable syntax overloads the bash syntax for subshells
# - script: cd src/api/python; echo $(Agent.TempDirectory)/musl-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion src/api/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools>=59", "wheel", "cmake"]
requires = ["setuptools>=70", "cmake"]
build-backend = "setuptools.build_meta"
35 changes: 23 additions & 12 deletions src/api/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from setuptools import setup
from setuptools.command.build import build as _build
from setuptools.command.sdist import sdist as _sdist
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
from setuptools.command.develop import develop as _develop

class LibError(Exception):
Expand All @@ -31,6 +32,8 @@ class LibError(Exception):
HEADER_DIRS = [os.path.join(SRC_DIR, 'src', 'api'), os.path.join(SRC_DIR, 'src', 'api', 'c++')]
RELEASE_METADATA = None
BUILD_PLATFORM = sys.platform
BUILD_ARCH = platform.machine()
BUILD_OS_VERSION = platform.mac_ver()[0].replace(".", "_")
else:
if not os.path.isdir(RELEASE_DIR):
raise Exception("RELEASE_DIR (%s) is not a directory!" % RELEASE_DIR)
Expand All @@ -41,6 +44,8 @@ class LibError(Exception):
raise Exception("RELEASE_DIR (%s) must be in the format z3-version-arch-os[-osversion] so we can extract metadata from it. Sorry!" % RELEASE_DIR)
RELEASE_METADATA.pop(0)
BUILD_PLATFORM = RELEASE_METADATA[2]
BUILD_ARCH = RELEASE_METADATA[1]
BUILD_OS_VERSION = RELEASE_METADATA[4].replace(".", "_") if len(RELEASE_METADATA) == 5 else None

# determine where destinations are
LIBS_DIR = os.path.join(ROOT_DIR, 'z3', 'lib')
Expand Down Expand Up @@ -231,8 +236,7 @@ def run(self):

class develop(_develop):
def run(self):
self.execute(_configure_z3, (), msg="Configuring Z3")
self.execute(_build_z3, (), msg="Building Z3")
self.execute(_configure_z3, (), msg="Configuring Z3") self.execute(_build_z3, (), msg="Building Z3")
self.execute(_copy_bins, (), msg="Copying binaries")
_develop.run(self)

Expand All @@ -242,21 +246,28 @@ def run(self):
self.execute(_copy_sources, (), msg="Copying source files")
_sdist.run(self)

# platform.freedesktop_os_release was added in 3.10
os_id = ''
if hasattr(platform, 'freedesktop_os_release'):
try:
osr = platform.freedesktop_os_release()
print(osr)
os_id = osr['ID']
except OSError:
pass
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
if BUILD_ARCH is not None and BUILD_PLATFORM is not None:
TAGS = {
# linux tags cannot be deployed - they must be auditwheel'd to pick the right compatibility tag based on imported libc symbol versions
("linux", "x86_64"): "linux_x86_64",
("linux", "aarch64"): "linux_aarch64",
# windows arm64 is not supported by pypi yet
("win", "x64"): "win_amd64",
("win", "x86"): "win32",
("darwin", "x86_64"): f"macosx_{BUILD_OS_VERSION}_x86_64",
("darwin", "x86_64"): f"macosx_{BUILD_OS_VERSION}_arm64",
} # type: dict[tuple[str, str], str]
self.plat_name = TAGS[(BUILD_PLATFORM, BUILD_ARCH)]
return super().finalize_options()


setup(
name='z3-solver',
version=_z3_version(),
description='an efficient SMT solver library',
long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html\n\nIn the event of technical difficulties related to configuration, compilation, or installation, please submit issues to https://github.com/z3prover/z3.git',
long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html',
author="The Z3 Theorem Prover Project",
maintainer="Audrey Dutcher and Nikolaj Bjorner",
maintainer_email="audrey@rhelmot.io",
Expand Down

0 comments on commit 3b57ba4

Please sign in to comment.