Skip to content

Commit 0837e3b

Browse files
authored
Fix nightly (#7365)
- add some logic to setup.py to handle cross platform tagging correctly this adds a dependency on setuptools>=70 - rearrange the nightly CI to use these new builds correctly
1 parent 5237e7d commit 0837e3b

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

scripts/nightly.yaml

+5-8
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ stages:
183183
- task: CopyFiles@2
184184
inputs:
185185
sourceFolder: src/api/python/wheelhouse
186-
contents: '*.zip'
186+
contents: '*.whl'
187187
targetFolder: $(Build.ArtifactStagingDirectory)
188188
- task: PublishPipelineArtifact@0
189189
inputs:
@@ -209,11 +209,11 @@ stages:
209209
- script: echo $PATH
210210
- script: "stat `which aarch64-none-linux-gnu-gcc`"
211211
- script: "pip install build git+https://github.com./rhelmot/auditwheel"
212-
- script: "cd src/api/python && CC=aarch64-none-linux-gnu-gcc CXX=aarch64-none-linux-gnu-g++ AR=aarch64-none-linux-gnu-ar LD=aarch64-none-linux-gnu-ld python -m build && AUDITWHEEL_PLAT= auditwheel repair --best-plat dist/*.whl && cd ../../.."
212+
- script: "cd src/api/python && CC=aarch64-none-linux-gnu-gcc CXX=aarch64-none-linux-gnu-g++ AR=aarch64-none-linux-gnu-ar LD=aarch64-none-linux-gnu-ld Z3_CROSS_COMPILING=aarch64 python -m build && AUDITWHEEL_PLAT= auditwheel repair --best-plat dist/*.whl && cd ../../.."
213213
- task: CopyFiles@2
214214
inputs:
215215
sourceFolder: src/api/python/wheelhouse
216-
contents: '*.zip'
216+
contents: '*.whl'
217217
targetFolder: $(Build.ArtifactStagingDirectory)
218218
- task: PublishPipelineArtifact@0
219219
inputs:
@@ -504,21 +504,18 @@ stages:
504504
targetPath: $(Agent.TempDirectory)
505505
- script: cd $(Agent.TempDirectory); mkdir osx-x64-bin; cd osx-x64-bin; unzip ../*x64-osx*.zip
506506
- script: cd $(Agent.TempDirectory); mkdir osx-arm64-bin; cd osx-arm64-bin; unzip ../*arm64-osx*.zip
507-
- script: cd $(Agent.TempDirectory); mkdir libc-x64-bin; cd libc-x64-bin; unzip ../*x64-glibc*.zip
508-
- script: cd $(Agent.TempDirectory); mkdir libc-arm64-bin; cd libc-arm64-bin; unzip ../*arm64-glibc*.zip
509507
# - script: cd $(Agent.TempDirectory); mkdir musl-bin; cd musl-bin; unzip ../*-linux.zip
510508
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
511509
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
512-
- script: python3 -m pip install --user -U setuptools wheel
510+
- script: python3 -m pip install --user -U setuptools
513511
- script: cd src/api/python; python3 setup.py sdist
514512
# 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
515-
- script: cd src/api/python; echo $(Agent.TempDirectory)/libc-x64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
516-
- script: cd src/api/python; echo $(Agent.TempDirectory)/libc-arm64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
517513
# - 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
518514
- script: cd src/api/python; echo $(Agent.TempDirectory)/win32-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
519515
- script: cd src/api/python; echo $(Agent.TempDirectory)/win64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
520516
- script: cd src/api/python; echo $(Agent.TempDirectory)/osx-x64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
521517
- script: cd src/api/python; echo $(Agent.TempDirectory)/osx-arm64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python3 setup.py bdist_wheel
518+
- script: cp $(Agent.TempDirectory)/*.whl src/api/python/dist
522519
- task: PublishPipelineArtifact@0
523520
inputs:
524521
artifactName: 'Python packages'

src/api/python/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=59", "wheel", "cmake"]
2+
requires = ["setuptools>=70", "cmake"]
33
build-backend = "setuptools.build_meta"

src/api/python/setup.py

+27-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from setuptools import setup
1010
from setuptools.command.build import build as _build
1111
from setuptools.command.sdist import sdist as _sdist
12+
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
1213
from setuptools.command.develop import develop as _develop
1314

1415
class LibError(Exception):
@@ -31,6 +32,8 @@ class LibError(Exception):
3132
HEADER_DIRS = [os.path.join(SRC_DIR, 'src', 'api'), os.path.join(SRC_DIR, 'src', 'api', 'c++')]
3233
RELEASE_METADATA = None
3334
BUILD_PLATFORM = sys.platform
35+
BUILD_ARCH = os.environ.get("Z3_CROSS_COMPILING", platform.machine())
36+
BUILD_OS_VERSION = platform.mac_ver()[0].split(".")
3437
else:
3538
if not os.path.isdir(RELEASE_DIR):
3639
raise Exception("RELEASE_DIR (%s) is not a directory!" % RELEASE_DIR)
@@ -41,6 +44,11 @@ class LibError(Exception):
4144
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)
4245
RELEASE_METADATA.pop(0)
4346
BUILD_PLATFORM = RELEASE_METADATA[2]
47+
BUILD_ARCH = RELEASE_METADATA[1]
48+
if len(RELEASE_METADATA) == 4:
49+
BUILD_OS_VERSION = RELEASE_METADATA[3].split(".")
50+
else:
51+
BUILD_OS_VERSION = None
4452

4553
# determine where destinations are
4654
LIBS_DIR = os.path.join(ROOT_DIR, 'z3', 'lib')
@@ -242,21 +250,29 @@ def run(self):
242250
self.execute(_copy_sources, (), msg="Copying source files")
243251
_sdist.run(self)
244252

245-
# platform.freedesktop_os_release was added in 3.10
246-
os_id = ''
247-
if hasattr(platform, 'freedesktop_os_release'):
248-
try:
249-
osr = platform.freedesktop_os_release()
250-
print(osr)
251-
os_id = osr['ID']
252-
except OSError:
253-
pass
253+
class bdist_wheel(_bdist_wheel):
254+
def finalize_options(self):
255+
if BUILD_ARCH is not None and BUILD_PLATFORM is not None:
256+
os_version_tag = '_'.join(BUILD_OS_VERSION[:2]) if BUILD_OS_VERSION is not None else 'xxxxxx'
257+
TAGS = {
258+
# linux tags cannot be deployed - they must be auditwheel'd to pick the right compatibility tag based on imported libc symbol versions
259+
("linux", "x86_64"): "linux_x86_64",
260+
("linux", "aarch64"): "linux_aarch64",
261+
# windows arm64 is not supported by pypi yet
262+
("win", "x64"): "win_amd64",
263+
("win", "x86"): "win32",
264+
("osx", "x64"): f"macosx_{os_version_tag}_x86_64",
265+
("osx", "arm64"): f"macosx_{os_version_tag}_arm64",
266+
} # type: dict[tuple[str, str], str]
267+
self.plat_name = TAGS[(BUILD_PLATFORM, BUILD_ARCH)]
268+
return super().finalize_options()
269+
254270

255271
setup(
256272
name='z3-solver',
257273
version=_z3_version(),
258274
description='an efficient SMT solver library',
259-
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',
275+
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',
260276
author="The Z3 Theorem Prover Project",
261277
maintainer="Audrey Dutcher and Nikolaj Bjorner",
262278
maintainer_email="[email protected]",
@@ -270,5 +286,5 @@ def run(self):
270286
'z3': [os.path.join('lib', '*'), os.path.join('include', '*.h'), os.path.join('include', 'c++', '*.h')]
271287
},
272288
data_files=[('bin',[os.path.join('bin',EXECUTABLE_FILE)])],
273-
cmdclass={'build': build, 'develop': develop, 'sdist': sdist},
289+
cmdclass={'build': build, 'develop': develop, 'sdist': sdist, 'bdist_wheel': bdist_wheel},
274290
)

0 commit comments

Comments
 (0)