Skip to content

Commit 8e7026a

Browse files
authored
PYTHON-2345 Ensure release files can be installed (mongodb#487)
1 parent e1915fc commit 8e7026a

File tree

5 files changed

+141
-27
lines changed

5 files changed

+141
-27
lines changed

.evergreen/build-mac.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash -ex
22

3+
# Get access to testinstall.
4+
. .evergreen/utils.sh
5+
6+
# Create temp directory for validated files.
7+
rm -rf validdist
8+
mkdir -p validdist
9+
mv dist/* validdist || true
10+
311
for VERSION in 2.7 3.4 3.5 3.6 3.7 3.8; do
412
if [[ $VERSION == "2.7" ]]; then
513
PYTHON=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
@@ -9,7 +17,27 @@ for VERSION in 2.7 3.4 3.5 3.6 3.7 3.8; do
917
PYTHON=/Library/Frameworks/Python.framework/Versions/$VERSION/bin/python3
1018
fi
1119
rm -rf build
12-
$PYTHON setup.py bdist_wheel
20+
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
1339
done
1440

41+
mv validdist/* dist
42+
rm -rf validdist
1543
ls dist
Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
#!/bin/bash -ex
2-
cd /pymongo
2+
cd /src
3+
4+
# Get access to testinstall.
5+
. .evergreen/utils.sh
6+
7+
# Create temp directory for validated files.
8+
rm -rf validdist
9+
mkdir -p validdist
10+
mv dist/* validdist || true
311

412
# Compile wheels
5-
for PYBIN in /opt/python/*/bin; do
13+
for PYTHON in /opt/python/*/bin/python; do
614
# Skip Python 3.3 and 3.9.
7-
if [[ "$PYBIN" == *"cp33"* || "$PYBIN" == *"cp39"* ]]; then
15+
if [[ "$PYTHON" == *"cp33"* || "$PYTHON" == *"cp39"* ]]; then
816
continue
917
fi
1018
# https://github.com/pypa/manylinux/issues/49
1119
rm -rf build
12-
${PYBIN}/python setup.py bdist_wheel
13-
done
20+
$PYTHON setup.py bdist_wheel
21+
rm -rf build
1422

15-
# https://github.com/pypa/manylinux/issues/49
16-
rm -rf build
23+
# Audit wheels and write multilinux tag
24+
for whl in dist/*.whl; do
25+
# Skip already built manylinux1 wheels.
26+
if [[ "$whl" != *"manylinux"* ]]; then
27+
auditwheel repair $whl -w dist
28+
rm $whl
29+
fi
30+
done
1731

18-
# Audit wheels and write multilinux1 tag
19-
for whl in dist/*.whl; do
20-
# Skip already built manylinux1 wheels.
21-
if [[ "$whl" != *"manylinux"* ]]; then
22-
auditwheel repair $whl -w dist
23-
rm $whl
24-
fi
32+
# Test that each wheel is installable.
33+
# Test without virtualenv because it's not present on manylinux containers.
34+
for release in dist/*; do
35+
testinstall $PYTHON $release "without-virtualenv"
36+
mv $release validdist/
37+
done
2538
done
39+
40+
mv validdist/* dist
41+
rm -rf validdist
42+
ls dist

.evergreen/build-manylinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ images=(quay.io/pypa/manylinux1_x86_64:2020-03-20-2fda31c \
1515

1616
for image in "${images[@]}"; do
1717
docker pull $image
18-
docker run --rm -v `pwd`:/pymongo $image /pymongo/.evergreen/build-manylinux-internal.sh
18+
docker run --rm -v `pwd`:/src $image /src/.evergreen/build-manylinux-internal.sh
1919
done
2020

2121
ls dist

.evergreen/build-windows.sh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
#!/bin/bash -ex
22

3+
# Get access to testinstall.
4+
. .evergreen/utils.sh
5+
6+
# Create temp directory for validated files.
7+
rm -rf validdist
8+
mkdir -p validdist
9+
mv dist/* validdist || true
10+
311
for VERSION in 27 34 35 36 37 38; do
4-
PYTHON=C:/Python/Python${VERSION}/python.exe
5-
PYTHON32=C:/Python/32/Python${VERSION}/python.exe
6-
if [[ $VERSION == "2.7" ]]; then
12+
_pythons=(C:/Python/Python${VERSION}/python.exe \
13+
C:/Python/32/Python${VERSION}/python.exe)
14+
for PYTHON in "${_pythons[@]}"; do
15+
if [[ $VERSION == "2.7" ]]; then
16+
rm -rf build
17+
$PYTHON setup.py bdist_egg
18+
fi
719
rm -rf build
8-
$PYTHON setup.py bdist_egg
9-
rm -rf build
10-
$PYTHON32 setup.py bdist_egg
11-
fi
12-
rm -rf build
13-
$PYTHON setup.py bdist_wheel
14-
rm -rf build
15-
$PYTHON32 setup.py bdist_wheel
20+
$PYTHON setup.py bdist_wheel
21+
22+
# Test that each wheel is installable.
23+
for release in dist/*; do
24+
testinstall $PYTHON $release
25+
mv $release validdist/
26+
done
27+
done
1628
done
1729

30+
mv validdist/* dist
31+
rm -rf validdist
1832
ls dist

.evergreen/utils.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash -ex
2+
3+
# Usage:
4+
# createvirtualenv /path/to/python /output/path/for/venv
5+
# * param1: Python binary to use for the virtualenv
6+
# * param2: Path to the virtualenv to create
7+
function createvirtualenv {
8+
PYTHON=$1
9+
VENVPATH=$2
10+
if $PYTHON -m virtualenv --version; then
11+
VIRTUALENV="$PYTHON -m virtualenv"
12+
elif command -v virtualenv; then
13+
VIRTUALENV="$(command -v virtualenv) -p $PYTHON"
14+
else
15+
echo "Cannot test without virtualenv"
16+
exit 1
17+
fi
18+
$VIRTUALENV --system-site-packages --never-download $VENVPATH
19+
if [ "Windows_NT" = "$OS" ]; then
20+
. $VENVPATH/Scripts/activate
21+
else
22+
. $VENVPATH/bin/activate
23+
fi
24+
}
25+
26+
# Usage:
27+
# testinstall /path/to/python /path/to/.whl/or/.egg ["no-virtualenv"]
28+
# * param1: Python binary to test
29+
# * param2: Path to the wheel or egg file to install
30+
# * param3 (optional): If set to a non-empty string, don't create a virtualenv. Used in manylinux containers.
31+
function testinstall {
32+
PYTHON=$1
33+
RELEASE=$2
34+
NO_VIRTUALENV=$3
35+
36+
if [ -z "$NO_VIRTUALENV" ]; then
37+
createvirtualenv $PYTHON venvtestinstall
38+
PYTHON=python
39+
fi
40+
41+
if [[ $RELEASE == *.egg ]]; then
42+
$PYTHON -m easy_install $RELEASE
43+
else
44+
$PYTHON -m pip install --upgrade $RELEASE
45+
fi
46+
cd tools
47+
$PYTHON fail_if_no_c.py
48+
$PYTHON -m pip uninstall -y pymongo
49+
cd ..
50+
51+
if [ -z "$NO_VIRTUALENV" ]; then
52+
deactivate
53+
rm -rf venvtestinstall
54+
fi
55+
}

0 commit comments

Comments
 (0)