Skip to content

Commit 519874d

Browse files
PYTHON-2663 Add manylinux* platform tags to linux wheels (#30)
1 parent 7d0be08 commit 519874d

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

.github/workflows/release-python-osx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ jobs:
6363
- uses: actions/checkout@v2
6464
- name: Build wheels
6565
run: |
66-
docker run --rm --volume `pwd`:/python --workdir /python --env PYTHON_BINARY=/opt/python/${{ matrix.python-version }}/bin/python quay.io/pypa/${{ matrix.container }} ./release.sh
66+
docker run --rm --volume `pwd`:/python --workdir /python --env PLAT=${{ matrix.container }} --env PYTHON_BINARY=/opt/python/${{ matrix.python-version }}/bin/python quay.io/pypa/${{ matrix.container }} ./release.sh
6767
working-directory: ./bindings/python
6868
- uses: actions/upload-artifact@v2
6969
with:
7070
name: pymongoarrow-${{ matrix.python-version }}-${{ matrix.container }}-wheel
71-
path: ./bindings/python/dist/*.whl
71+
path: ./bindings/python/wheelhouse/*.whl
7272
if-no-files-found: error
7373
test-manylinux-wheels:
7474
runs-on: ubuntu-latest

bindings/python/THIRD-PARTY-NOTICES

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
PyMongoArrow uses third-party libraries or other resources that may
2+
be distributed under licenses different than the PyMongoArrow software.
3+
4+
In the event that we accidentally failed to list a required notice,
5+
please bring it to our attention through any of the ways detailed here:
6+
7+
8+
9+
The attached notices are provided for information only.
10+
11+
For any licenses that require disclosure of source, sources are available at
12+
https://github.com/mongodb-labs/mongo-arrow/.
13+
14+
15+
1) License Notice for addtags.py
16+
--------------------------------
17+
18+
The addtags.py file was adapted from auditwheel (https://github.com/pypa/auditwheel).
19+
20+
The MIT License
21+
22+
Copyright (c) 2016 Robert T. McGibbon <[email protected]>
23+
24+
Permission is hereby granted, free of charge, to any person obtaining a copy
25+
of this software and associated documentation files (the "Software"), to deal
26+
in the Software without restriction, including without limitation the rights
27+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28+
copies of the Software, and to permit persons to whom the Software is
29+
furnished to do so, subject to the following conditions:
30+
31+
The above copyright notice and this permission notice shall be included in
32+
all copies or substantial portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40+
THE SOFTWARE.

bindings/python/addtags.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python3
2+
# Dependencies:
3+
# - auditwheel>=3,<4
4+
# Usage:
5+
# $ python addtags.py WHEEL_PATH TARGET_PLATFORM WHEEL_DIR
6+
import os
7+
from os.path import abspath, isfile, exists, basename, join as pjoin
8+
from sys import argv
9+
from auditwheel.policy import get_priority_by_name, get_replace_platforms
10+
from auditwheel.wheel_abi import analyze_wheel_abi
11+
from auditwheel.wheeltools import InWheelCtx, add_platforms
12+
13+
14+
def repair_wheel(wheel_path, abi, wheel_dir):
15+
wheel_fname = basename(wheel_path)
16+
with InWheelCtx(wheel_path) as ctx:
17+
ctx.out_wheel = pjoin(wheel_dir, wheel_fname)
18+
ctx.out_wheel = add_platforms(ctx, [abi],
19+
get_replace_platforms(abi))
20+
return ctx.out_wheel
21+
22+
23+
def main(wheel_path, abi, wheel_dir):
24+
if not isfile(wheel_path):
25+
raise FileNotFoundError('cannot access wheel file %s' % (wheel_path,))
26+
27+
if not exists(wheel_dir):
28+
os.makedirs(wheel_dir)
29+
30+
reqd_tag = get_priority_by_name(abi)
31+
out_wheel = repair_wheel(wheel_path, abi, wheel_dir)
32+
33+
if out_wheel is not None:
34+
analyzed_tag = analyze_wheel_abi(out_wheel).overall_tag
35+
if reqd_tag < get_priority_by_name(analyzed_tag):
36+
print('Wheel is eligible for a higher priority tag. '
37+
'You requested %s but I have found this wheel is '
38+
'eligible for %s.' % (abi, analyzed_tag))
39+
out_wheel = repair_wheel(wheel_path, analyzed_tag, wheel_dir)
40+
41+
print('Fixed-up wheel written to %s' % (out_wheel,))
42+
43+
44+
if __name__ == '__main__':
45+
WHEEL_PATH, TARGET_PLATFORM, WHEEL_DIR = argv[1], argv[2], argv[3]
46+
main(
47+
wheel_path=abspath(WHEEL_PATH),
48+
abi=TARGET_PLATFORM,
49+
wheel_dir=abspath(WHEEL_DIR))

bindings/python/release.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ $PYTHON -c "import pyarrow; pyarrow.create_library_symlinks()"
4646

4747
# Build wheels in $(pwd)/dist/*.whl
4848
LIBBSON_INSTALL_DIR="$LIBBSON_INSTALL_DIR" $PYTHON setup.py bdist_wheel
49+
50+
# Run auditwheel repair to set platform tags on Linux
51+
if [ "Linux" = "$(uname -s)" ]
52+
then
53+
$PYTHON -m pip install auditwheel
54+
$PYTHON addtags.py dist/*.whl "$PLAT" ./wheelhouse
55+
fi

0 commit comments

Comments
 (0)