Skip to content

Commit b2e114e

Browse files
authored
Better python wheels to support 3.8.0+ (#157)
* Support different manylinux naming conventions * fix * fix enum * update reqs * update comments * comments * update CI CD
1 parent a681cd4 commit b2e114e

File tree

6 files changed

+78
-29
lines changed

6 files changed

+78
-29
lines changed

.github/workflows/CD.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ jobs:
9696

9797
# Publish python releases only if all other tests have passed after creating a
9898
# release.
99+
Publish-python-legacy:
100+
needs: [Core, JS, Go, Python, Rust]
101+
if: ${{ github.event_name == 'release' }}
102+
runs-on: ${{ matrix.os }}
103+
strategy:
104+
matrix:
105+
# Handling boundary conditions of: https://github.com/pypa/manylinux
106+
python-version: ['3.8.0', '3.8.4', '3.9.0']
107+
os: [ubuntu-20.04]
108+
steps:
109+
- uses: actions/checkout@v3
110+
- name: Set up Python
111+
uses: actions/setup-python@v4
112+
with:
113+
python-version: ${{ matrix.python-version }}
114+
- name: Build and publish the python wheel
115+
env:
116+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
117+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
118+
run: |
119+
python -m pip install --upgrade pip
120+
pip install twine packaging
121+
bazel build -c opt //private_set_intersection/python:wheel
122+
python private_set_intersection/python/rename.py
123+
twine upload --skip-existing bazel-bin/private_set_intersection/python/openmined.psi-*
99124
Publish-python:
100125
needs: [Core, JS, Go, Python, Rust]
101126
if: ${{ github.event_name == 'release' }}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#!/bin/sh
22
set -e
33

4-
python -m pip install --upgrade pip
54
pip install -r private_set_intersection/python/requirements.txt
65

76
# Python + Bazel
87
bazel test -c opt --test_output=all //private_set_intersection/python:tests
9-
10-
# Python package
11-
# pip install .
12-
# python private_set_intersection/python/tests.py

private_set_intersection/python/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ py_wheel(
9797
"@bazel_tools//src/conditions:windows_arm64": "win_arm64",
9898
"@bazel_tools//src/conditions:darwin_x86_64": "macosx_12_0_x86_64",
9999
"@bazel_tools//src/conditions:darwin_arm64": "macosx_12_0_arm64",
100-
"@bazel_tools//src/conditions:linux_x86_64": "manylinux_GLIBC_x86_64",
101-
"@bazel_tools//src/conditions:linux_aarch64": "manylinux_GLIBC_aarch64",
100+
"@bazel_tools//src/conditions:linux_x86_64": "LINUX_x86_64",
101+
"@bazel_tools//src/conditions:linux_aarch64": "LINUX_aarch64",
102102
}),
103-
python_requires = ">=3.8.10", # Required for linux's wheel naming convention
103+
python_requires = ">=3.8.0",
104104
python_tag = "INTERPRETER",
105105
requires = ["protobuf>=3.20"],
106106
version = VERSION_LABEL,

private_set_intersection/python/rename.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
# This file is used to rename the wheel generated via py_wheel with values
22
# determined at runtime
33
import sys, os, re, platform
4-
from packaging import tags
4+
from packaging import tags, version
5+
from platform import python_version
6+
from enum import Enum
7+
8+
9+
class ABIVersion(Enum):
10+
MANY_LINUX_X_Y = "manylinux_" + str(platform.libc_ver()[1].replace(".", "_"))
11+
MANY_LINUX_2014 = "manylinux2014"
12+
MANY_LINUX_2010 = "manylinux2010"
13+
14+
15+
# We rely on the bundled pip versions installed with python to determine the
16+
# naming variant: https://github.com/pypa/manylinux
17+
#
18+
# NOTE: Order matters
19+
python_versions = {
20+
version.parse("3.10.0"): ABIVersion.MANY_LINUX_X_Y,
21+
version.parse("3.9.5"): ABIVersion.MANY_LINUX_X_Y,
22+
version.parse("3.9.0"): ABIVersion.MANY_LINUX_2014,
23+
version.parse("3.8.10"): ABIVersion.MANY_LINUX_X_Y,
24+
version.parse("3.8.4"): ABIVersion.MANY_LINUX_2014,
25+
version.parse("3.8.0"): ABIVersion.MANY_LINUX_2010, # Fails for aarch64
26+
}
527

628

729
def main():
@@ -17,17 +39,22 @@ def main():
1739
interpreter_version = tags.interpreter_version()
1840
abi_tag = interpreter_name + interpreter_version
1941

20-
# openmined.psi-1.0.0-INTERPRETER-ABI-PLATFORM.whl
42+
# openmined.psi-1.0.0-INTERPRETER-ABI-PLATFORM-ARCH.whl
2143
# INTERPRETER and ABI should be the same value
2244
outfile = re.sub(r"INTERPRETER", abi_tag, inputfile)
2345
outfile = re.sub(r"ABI", abi_tag, outfile)
2446
system = platform.system()
2547

26-
# Rename the wheel depending on the version of glibc
48+
# We rename the wheel depending on the version of python and glibc
2749
if system.lower() == "linux":
28-
version = platform.libc_ver()[1]
29-
glibc_version = version.replace(".", "_")
30-
outfile = re.sub(r"GLIBC", glibc_version, outfile)
50+
current_version = version.parse(python_version())
51+
manylinux = ABIVersion.MANY_LINUX_X_Y.value
52+
for (ver, ml) in python_versions.items():
53+
if current_version >= ver:
54+
manylinux = ml.value
55+
break
56+
57+
outfile = re.sub(r"LINUX", manylinux, outfile)
3158

3259
print("renaming ", inputfile, outfile)
3360
os.rename(inputfile, outfile)

private_set_intersection/python/requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
black==22.12.0
2-
flake8==6.0.0
2+
flake8==5.0.4 # must be 5.x for python 3.8
33
pytest==7.2.0
44
pytest-benchmark==4.0.0
55
twine==4.0.2

private_set_intersection/python/requirements.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,38 @@ attrs==22.2.0
88
# via pytest
99
black==22.12.0
1010
# via -r requirements.in
11-
bleach==5.0.1
11+
bleach==6.0.0
1212
# via readme-renderer
1313
certifi==2022.12.7
1414
# via requests
15-
charset-normalizer==2.1.1
15+
charset-normalizer==3.0.1
1616
# via requests
1717
click==8.1.3
1818
# via black
19-
commonmark==0.9.1
20-
# via rich
2119
docutils==0.19
2220
# via readme-renderer
2321
exceptiongroup==1.1.0
2422
# via pytest
25-
flake8==6.0.0
23+
flake8==5.0.4
2624
# via -r requirements.in
2725
idna==3.4
2826
# via requests
2927
importlib-metadata==6.0.0
3028
# via
3129
# keyring
3230
# twine
33-
iniconfig==1.1.1
31+
iniconfig==2.0.0
3432
# via pytest
3533
jaraco-classes==3.2.3
3634
# via keyring
3735
keyring==23.13.1
3836
# via twine
37+
markdown-it-py==2.1.0
38+
# via rich
3939
mccabe==0.7.0
4040
# via flake8
41+
mdurl==0.1.2
42+
# via markdown-it-py
4143
more-itertools==9.0.0
4244
# via jaraco-classes
4345
mypy-extensions==0.4.3
@@ -46,9 +48,9 @@ packaging==22.0
4648
# via
4749
# -r requirements.in
4850
# pytest
49-
pathspec==0.10.3
51+
pathspec==0.11.0
5052
# via black
51-
pkginfo==1.9.5
53+
pkginfo==1.9.6
5254
# via twine
5355
platformdirs==2.6.2
5456
# via black
@@ -58,9 +60,9 @@ protobuf==4.21.12
5860
# via -r requirements.in
5961
py-cpuinfo==9.0.0
6062
# via pytest-benchmark
61-
pycodestyle==2.10.0
63+
pycodestyle==2.9.1
6264
# via flake8
63-
pyflakes==3.0.1
65+
pyflakes==2.5.0
6466
# via flake8
6567
pygments==2.14.0
6668
# via
@@ -74,15 +76,15 @@ pytest-benchmark==4.0.0
7476
# via -r requirements.in
7577
readme-renderer==37.3
7678
# via twine
77-
requests==2.28.1
79+
requests==2.28.2
7880
# via
7981
# requests-toolbelt
8082
# twine
8183
requests-toolbelt==0.10.1
8284
# via twine
8385
rfc3986==2.0.0
8486
# via twine
85-
rich==13.0.1
87+
rich==13.3.1
8688
# via twine
8789
six==1.16.0
8890
# via bleach
@@ -92,11 +94,11 @@ tomli==2.0.1
9294
# pytest
9395
twine==4.0.2
9496
# via -r requirements.in
95-
urllib3==1.26.13
97+
urllib3==1.26.14
9698
# via
9799
# requests
98100
# twine
99101
webencodings==0.5.1
100102
# via bleach
101-
zipp==3.11.0
103+
zipp==3.12.0
102104
# via importlib-metadata

0 commit comments

Comments
 (0)