Skip to content

Commit ec5b148

Browse files
rhelmotNikolajBjorner
authored andcommitted
Add python packaging build and deployment with Azure
1 parent eec550e commit ec5b148

File tree

4 files changed

+120
-14
lines changed

4 files changed

+120
-14
lines changed

scripts/mk_unix_dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def check_build_dir(path):
107107
# Create a build directory using mk_make.py
108108
def mk_build_dir(path):
109109
if not check_build_dir(path) or FORCE_MK:
110-
opts = ["python", os.path.join('scripts', 'mk_make.py'), "-b", path, "--staticlib"]
110+
opts = [sys.executable, os.path.join('scripts', 'mk_make.py'), "-b", path, "--staticlib"]
111111
if DOTNET_CORE_ENABLED:
112112
opts.append('--dotnet')
113113
if not DOTNET_KEY_FILE is None:

scripts/nightly.yaml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
artifactName: 'Mac'
1818
targetPath: $(Build.ArtifactStagingDirectory)
1919

20-
2120
- job: Ubuntu
2221
displayName: "Ubuntu build"
2322
pool:
@@ -35,6 +34,23 @@ jobs:
3534
artifactName: 'Ubuntu'
3635
targetPath: $(Build.ArtifactStagingDirectory)
3736

37+
- job: Manylinux
38+
displayName: "Manylinux build"
39+
pool:
40+
vmImage: "ubuntu-16.04"
41+
container: "rhelmot/manylinux1_x86_64:latest"
42+
variables:
43+
python: "/opt/python/cp35-cp35m/bin/python"
44+
steps:
45+
- script: $(python) scripts/mk_unix_dist.py --nodotnet --nojava
46+
- script: git clone https://github.com/z3prover/z3test z3test
47+
- script: $(python) z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
48+
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/
49+
- task: PublishPipelineArtifact@0
50+
inputs:
51+
artifactName: 'Manylinux'
52+
targetPath: $(Build.ArtifactStagingDirectory)
53+
3854
- job: Windows
3955
displayName: "Windows build"
4056
pool:
@@ -52,6 +68,36 @@ jobs:
5268
artifactName: 'Windows'
5369
targetPath: $(Build.ArtifactStagingDirectory)
5470

71+
- job: Python
72+
displayName: "Python packaging"
73+
dependsOn:
74+
- Manylinux
75+
- Windows
76+
pool:
77+
vmImage: "ubuntu-16.04"
78+
steps:
79+
- task: DownloadPipelineArtifact@0
80+
inputs:
81+
artifactName: 'Windows'
82+
targetPath: $(Agent.TempDirectory)
83+
- task: DownloadPipelineArtifact@0
84+
inputs:
85+
artifactName: 'Manylinux'
86+
targetPath: $(Agent.TempDirectory)
87+
- script: cd $(Agent.TempDirectory); mkdir linux-bin; cd linux-bin; unzip ../*centos*.zip
88+
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
89+
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
90+
- script: python -m pip install --user -U setuptools wheel
91+
- script: cd src/api/python; python setup.py sdist
92+
# 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
93+
- script: cd src/api/python; echo $(Agent.TempDirectory)/linux-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
94+
- script: cd src/api/python; echo $(Agent.TempDirectory)/win32-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
95+
- script: cd src/api/python; echo $(Agent.TempDirectory)/win64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
96+
- task: PublishPipelineArtifact@0
97+
inputs:
98+
artifactName: 'Python packages'
99+
targetPath: src/api/python/dist
100+
55101
- job: Deploy
56102
displayName: "Deploy into GitHub"
57103
dependsOn:

scripts/release.yml

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ jobs:
1010
secureFile: 'z3.snk'
1111
- script: python scripts/mk_unix_dist.py --dotnet-key=$(Agent.TempDirectory)/z3.snk
1212
- script: git clone https://github.com/z3prover/z3test z3test
13-
- script: python z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
13+
- script: python z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
1414
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/.
1515
- task: PublishPipelineArtifact@0
1616
inputs:
1717
artifactName: 'Mac'
1818
targetPath: $(Build.ArtifactStagingDirectory)
1919

20-
2120
- job: Ubuntu
2221
displayName: "Ubuntu build"
2322
pool:
@@ -28,13 +27,30 @@ jobs:
2827
secureFile: 'z3.snk'
2928
- script: python scripts/mk_unix_dist.py --dotnet-key=$(Agent.TempDirectory)/z3.snk
3029
- script: git clone https://github.com/z3prover/z3test z3test
31-
- script: python z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
30+
- script: python z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
3231
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/.
3332
- task: PublishPipelineArtifact@0
3433
inputs:
3534
artifactName: 'Ubuntu'
3635
targetPath: $(Build.ArtifactStagingDirectory)
3736

37+
- job: Manylinux
38+
displayName: "Manylinux build"
39+
pool:
40+
vmImage: "ubuntu-16.04"
41+
container: "rhelmot/manylinux1_x86_64:latest"
42+
variables:
43+
python: "/opt/python/cp35-cp35m/bin/python"
44+
steps:
45+
- script: $(python) scripts/mk_unix_dist.py --nodotnet --nojava
46+
- script: git clone https://github.com/z3prover/z3test z3test
47+
- script: $(python) z3test/scripts/test_benchmarks.py build-dist/z3 z3test/regressions/smt2
48+
- script: cp dist/*.zip $(Build.ArtifactStagingDirectory)/
49+
- task: PublishPipelineArtifact@0
50+
inputs:
51+
artifactName: 'Manylinux'
52+
targetPath: $(Build.ArtifactStagingDirectory)
53+
3854
- job: Windows
3955
displayName: "Windows build"
4056
pool:
@@ -43,19 +59,50 @@ jobs:
4359
- task: DownloadSecureFile@1
4460
inputs:
4561
secureFile: 'z3.snk'
46-
- script: scripts\mk_win_dist.cmd
62+
- script: scripts\mk_win_dist.cmd
4763
- script: xcopy dist\*.zip $(Build.ArtifactStagingDirectory)\* /y
4864
- task: PublishPipelineArtifact@0
4965
inputs:
5066
artifactName: 'Windows'
5167
targetPath: $(Build.ArtifactStagingDirectory)
5268

69+
- job: Python
70+
displayName: "Python packaging"
71+
dependsOn:
72+
- Manylinux
73+
- Windows
74+
pool:
75+
vmImage: "ubuntu-16.04"
76+
steps:
77+
- task: DownloadPipelineArtifact@0
78+
inputs:
79+
artifactName: 'Windows'
80+
targetPath: $(Agent.TempDirectory)
81+
- task: DownloadPipelineArtifact@0
82+
inputs:
83+
artifactName: 'Manylinux'
84+
targetPath: $(Agent.TempDirectory)
85+
- script: cd $(Agent.TempDirectory); mkdir linux-bin; cd linux-bin; unzip ../*centos*.zip
86+
- script: cd $(Agent.TempDirectory); mkdir win32-bin; cd win32-bin; unzip ../*x86-win*.zip
87+
- script: cd $(Agent.TempDirectory); mkdir win64-bin; cd win64-bin; unzip ../*x64-win*.zip
88+
- script: python -m pip install --user -U setuptools wheel
89+
- script: cd src/api/python; python setup.py sdist
90+
# 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
91+
- script: cd src/api/python; echo $(Agent.TempDirectory)/linux-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
92+
- script: cd src/api/python; echo $(Agent.TempDirectory)/win32-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
93+
- script: cd src/api/python; echo $(Agent.TempDirectory)/win64-bin/* | xargs printf 'PACKAGE_FROM_RELEASE=%s\n' | xargs -I '{}' env '{}' python setup.py bdist_wheel
94+
- task: PublishPipelineArtifact@0
95+
inputs:
96+
artifactName: 'Python packages'
97+
targetPath: src/api/python/dist
98+
5399
- job: Deploy
54-
displayName: "Deploy into GitHub"
55-
dependsOn:
100+
displayName: "Deploy into GitHub and PyPI"
101+
dependsOn:
56102
- Mac
57103
- Ubuntu
58104
- Windows
105+
- Python
59106
steps:
60107
- task: DownloadPipelineArtifact@0
61108
inputs:
@@ -69,10 +116,6 @@ jobs:
69116
inputs:
70117
artifactName: 'Ubuntu'
71118
targetPath: tmp
72-
- task: CopyFiles@2
73-
inputs:
74-
sourceFolder: $(Build.ArtifactStagingDirectory)
75-
targetFolder: tmp
76119
# TBD: build NuGet package
77120
# TBD: this script should build a specific pre-specified tag
78121
- task: GitHubRelease@0
@@ -89,6 +132,16 @@ jobs:
89132
assets: 'tmp/*'
90133
isDraft: true
91134
isPreRelease: true
135+
- task: DownloadPipelineArtifact@0
136+
inputs:
137+
artifactName: 'Python packages'
138+
targetPath: dist
139+
- task: DownloadSecureFile@1
140+
name: pypirc
141+
inputs:
142+
secureFile: 'pypirc'
143+
- script: python -m pip install --user -U setuptools wheel twine
144+
- script: python -m twine upload --config-file $(pypirc.secureFilePath) -r $(pypiReleaseServer) dist/*
92145

93146

94147
# TBD: run regression tests on generated binaries.

src/api/python/setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
RELEASE_METADATA = None
3434
BUILD_PLATFORM = sys.platform
3535
else:
36+
if not os.path.isdir(RELEASE_DIR):
37+
raise Exception("RELEASE_DIR (%s) is not a directory!" % RELEASE_DIR)
3638
BUILD_DIR = os.path.join(RELEASE_DIR, 'bin')
3739
HEADER_DIRS = [os.path.join(RELEASE_DIR, 'include')]
3840
RELEASE_METADATA = os.path.basename(RELEASE_DIR).split('-')
3941
if RELEASE_METADATA[0] != 'z3' or len(RELEASE_METADATA) not in (4, 5):
40-
raise Exception("RELEASE_DIR must be in the format z3-version-arch-os[-osversion] so we can extract metadata from it. Sorry!")
42+
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)
4143
RELEASE_METADATA.pop(0)
4244
BUILD_PLATFORM = RELEASE_METADATA[2]
4345

@@ -225,7 +227,12 @@ def run(self):
225227
distos = RELEASE_METADATA[2]
226228
if distos in ('debian', 'ubuntu') or 'linux' in distos:
227229
raise Exception("Linux binary distributions must be built on centos to conform to PEP 513")
228-
if distos == 'win':
230+
elif distos == 'centos':
231+
if arch == 'x64':
232+
plat_name = 'manylinux1_x86_64'
233+
else:
234+
plat_name = 'manylinux1_i686'
235+
elif distos == 'win':
229236
if arch == 'x64':
230237
plat_name = 'win_amd64'
231238
else:

0 commit comments

Comments
 (0)