Skip to content

Commit 1019c91

Browse files
authored
PYTHON-3424 PyMongo Universal Wheels Are Improperly Compiled (#1051)
1 parent e3ff041 commit 1019c91

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

.evergreen/build-mac.sh

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

11-
for VERSION in 3.7 3.8 3.9 3.10; do
12-
PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
13-
rm -rf build
11+
VERSION=${VERSION:-3.10}
12+
PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
13+
rm -rf build
1414

15-
createvirtualenv $PYTHON releasevenv
16-
python -m pip install --upgrade wheel
17-
python -m pip install setuptools==63.2.0
18-
python setup.py bdist_wheel
19-
deactivate || true
20-
rm -rf releasevenv
15+
createvirtualenv $PYTHON releasevenv
16+
python -m pip install --upgrade wheel
17+
python -m pip install setuptools==63.2.0
18+
python setup.py bdist_wheel
19+
deactivate || true
20+
rm -rf releasevenv
2121

22-
# Test that each wheel is installable.
23-
for release in dist/*; do
24-
testinstall $PYTHON $release
25-
mv $release validdist/
26-
done
22+
# Test that each wheel is installable.
23+
for release in dist/*; do
24+
testinstall $PYTHON $release
25+
mv $release validdist/
2726
done
2827

2928
mv validdist/* dist

.evergreen/config.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ functions:
891891
script: |
892892
set -o xtrace
893893
${PREPARE_SHELL}
894-
.evergreen/release.sh
894+
VERSION=${VERSION} ENSURE_UNIVERSAL2=${ENSURE_UNIVERSAL2} .evergreen/release.sh
895895
896896
"upload release":
897897
- command: archive.targz_pack
@@ -1046,11 +1046,30 @@ tasks:
10461046
genhtml --version || true
10471047
valgrind --version || true
10481048
1049-
- name: "release-mac"
1049+
- name: "release-mac-1100"
1050+
tags: ["release_tag"]
1051+
run_on: macos-1100
1052+
commands:
1053+
- func: "build release"
1054+
vars:
1055+
VERSION: "3.10"
1056+
ENSURE_UNIVERSAL2: "1"
1057+
- func: "build release"
1058+
vars:
1059+
VERSION: "3.9"
1060+
ENSURE_UNIVERSAL2: "1"
1061+
- func: "upload release"
1062+
1063+
- name: "release-mac-1014"
10501064
tags: ["release_tag"]
10511065
run_on: macos-1014
10521066
commands:
10531067
- func: "build release"
1068+
vars:
1069+
VERSION: "3.7"
1070+
- func: "build release"
1071+
vars:
1072+
VERSION: "3.8"
10541073
- func: "upload release"
10551074

10561075
- 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(f"{parent_dir}/**/*.so"):
36+
print(f"Checking universal2 compatibility in {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)