Skip to content

Commit 660b80a

Browse files
authored
PYTHON-3424 PyMongo Universal Wheels Are Improperly Compiled (#1053)
1 parent 0869a5e commit 660b80a

File tree

3 files changed

+69
-28
lines changed

3 files changed

+69
-28
lines changed

.evergreen/build-mac.sh

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@ rm -rf validdist
88
mkdir -p validdist
99
mv dist/* validdist || true
1010

11-
for VERSION in 2.7 3.4 3.5 3.6 3.7 3.8 3.9 3.10; do
12-
if [[ $VERSION == "2.7" ]]; then
13-
PYTHON=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
14-
rm -rf build
15-
$PYTHON setup.py bdist_egg
16-
else
17-
PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
18-
fi
11+
VERSION=${VERSION:-3.10}
12+
if [[ $VERSION == "2.7" ]]; then
13+
PYTHON=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
1914
rm -rf build
15+
$PYTHON setup.py bdist_egg
16+
else
17+
PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
18+
fi
2019

21-
# Install wheel if not already there.
22-
if ! $PYTHON -m wheel version; then
23-
createvirtualenv $PYTHON releasevenv
24-
WHEELPYTHON=python
25-
pip install --upgrade wheel
26-
else
27-
WHEELPYTHON=$PYTHON
28-
fi
29-
30-
$WHEELPYTHON setup.py bdist_wheel
31-
deactivate || true
32-
rm -rf releasevenv
33-
34-
# Test that each wheel is installable.
35-
for release in dist/*; do
36-
testinstall $PYTHON $release
37-
mv $release validdist/
38-
done
20+
rm -rf build
21+
22+
# Install wheel if not already there.
23+
if ! $PYTHON -m wheel version; then
24+
createvirtualenv $PYTHON releasevenv
25+
WHEELPYTHON=python
26+
pip install --upgrade wheel setuptools==63.2.0
27+
else
28+
WHEELPYTHON=$PYTHON
29+
fi
30+
31+
$WHEELPYTHON setup.py bdist_wheel
32+
deactivate || true
33+
rm -rf releasevenv
34+
35+
# Test that each wheel is installable.
36+
for release in dist/*; do
37+
testinstall $PYTHON $release
38+
mv $release validdist/
3939
done
4040

4141
mv validdist/* dist

.evergreen/config.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ functions:
846846
script: |
847847
set -o xtrace
848848
${PREPARE_SHELL}
849-
.evergreen/release.sh
849+
VERSION=${VERSION} ENSURE_UNIVERSAL2=${ENSURE_UNIVERSAL2} .evergreen/release.sh
850850
851851
"upload release":
852852
- command: archive.targz_pack
@@ -1002,11 +1002,39 @@ tasks:
10021002
genhtml --version || true
10031003
valgrind --version || true
10041004
1005-
- name: "release-mac"
1005+
- name: "release-mac-1100"
1006+
tags: ["release_tag"]
1007+
run_on: macos-1100
1008+
commands:
1009+
- func: "build release"
1010+
vars:
1011+
VERSION: "3.10"
1012+
ENSURE_UNIVERSAL2: "1"
1013+
- func: "build release"
1014+
vars:
1015+
VERSION: "3.9"
1016+
ENSURE_UNIVERSAL2: "1"
1017+
- func: "upload release"
1018+
1019+
- name: "release-mac-1014"
10061020
tags: ["release_tag"]
10071021
run_on: macos-1014
10081022
commands:
10091023
- func: "build release"
1024+
vars:
1025+
VERSION: "2.7"
1026+
- func: "build release"
1027+
vars:
1028+
VERSION: "3.5"
1029+
- func: "build release"
1030+
vars:
1031+
VERSION: "3.6"
1032+
- func: "build release"
1033+
vars:
1034+
VERSION: "3.7"
1035+
- func: "build release"
1036+
vars:
1037+
VERSION: "3.8"
10101038
- func: "upload release"
10111039

10121040
- name: "release-windows"

tools/fail_if_no_c.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
Only really intended to be used by internal build scripts.
1818
"""
1919

20+
import glob
21+
import os
22+
import subprocess
2023
import sys
2124

2225
sys.path[0:0] = [""]
@@ -26,3 +29,13 @@
2629

2730
if not pymongo.has_c() or not bson.has_c():
2831
sys.exit("could not load C extensions")
32+
33+
if os.environ.get("ENSURE_UNIVERSAL2") == "1":
34+
parent_dir = os.path.dirname(pymongo.__path__[0])
35+
for so_file in glob.glob("%s/**/*.so" % parent_dir):
36+
print("Checking universal2 compatibility in %s..." % so_file)
37+
output = subprocess.check_output(["file", so_file])
38+
if "arm64" not in output.decode("utf-8"):
39+
sys.exit("Universal wheel was not compiled with arm64 support")
40+
if "x86_64" not in output.decode("utf-8"):
41+
sys.exit("Universal wheel was not compiled with x86_64 support")

0 commit comments

Comments
 (0)