Unverified Commit e5e9d189 authored by Matthew Brett's avatar Matthew Brett Committed by GitHub
Browse files

Merge pull request #302 from matthew-brett/add-supported-wheels-test

MRG: Use packaging; add test for supported wheels

Replace internal pip code with packaging code (thanks @pfmoore).

Add tests for supported_wheels.py script.
parents 0c4a9920 02469b8e
...@@ -336,6 +336,7 @@ function install_wheel { ...@@ -336,6 +336,7 @@ function install_wheel {
done <<< "$TEST_DEPENDS" done <<< "$TEST_DEPENDS"
fi fi
# Install compatible wheel # Install compatible wheel
pip install packaging
pip install $(pip_opts) $@ \ pip install $(pip_opts) $@ \
$(python $MULTIBUILD_DIR/supported_wheels.py $wheelhouse/*.whl) $(python $MULTIBUILD_DIR/supported_wheels.py $wheelhouse/*.whl)
} }
......
...@@ -6,15 +6,13 @@ from __future__ import print_function ...@@ -6,15 +6,13 @@ from __future__ import print_function
import sys import sys
from os.path import basename from os.path import basename
from packaging.tags import sys_tags
try: try:
from wheel.install import WHEEL_INFO_RE as wheel_matcher from wheel.install import WHEEL_INFO_RE as wheel_matcher
except ImportError: # As of Wheel 0.32.0 except ImportError: # As of Wheel 0.32.0
from wheel.wheelfile import WHEEL_INFO_RE from wheel.wheelfile import WHEEL_INFO_RE
wheel_matcher = WHEEL_INFO_RE.match wheel_matcher = WHEEL_INFO_RE.match
try:
from pip.pep425tags import get_supported
except ImportError: # pip 10
from pip._internal.pep425tags import get_supported
def tags_for(fname): def tags_for(fname):
...@@ -28,11 +26,8 @@ def tags_for(fname): ...@@ -28,11 +26,8 @@ def tags_for(fname):
def main(): def main():
# Up to pip < 20, get_supported() returns a list of tuples; from pip >= 20, supported = {(tag.interpreter, tag.abi, tag.platform)
# it returns a list of packaging.tags.Tag objects. We try to support both. for tag in sys_tags()
supported = {
(tag.interpreter, tag.abi, tag.platform) if not isinstance(tag, tuple) else tag
for tag in get_supported()
} }
for fname in sys.argv[1:]: for fname in sys.argv[1:]:
tags = set(tags_for(fname)) tags = set(tags_for(fname))
......
# Test supported wheels script # Test supported wheels script
PYTHON_EXE=${PYTHON_EXE:-python} PYTHON_EXE=${PYTHON_EXE:-python}
if [ -z "$PIP_CMD" ]; then if [ -z "$PIP_CMD" ]; then
pip_install="pip install --user" pip_install="$PYTHON_EXE -m pip install --user"
else else
pip_install="$PIP_CMD install" pip_install="$PIP_CMD install"
fi fi
# Current wheel versions not available for older Pythons # Needed for supported_wheels script
$pip_install packaging
# Current wheel versions not available for older Pythons.
lpv=$(lex_ver $MB_PYTHON_VERSION) lpv=$(lex_ver $MB_PYTHON_VERSION)
# Check no errors.
if [ $lpv -ge $(lex_ver 3.5) ] || [ $lpv -lt $(lex_ver 3) ]; then if [ $lpv -ge $(lex_ver 3.5) ] || [ $lpv -lt $(lex_ver 3) ]; then
for whl in wheel==0.31.1 wheel==0.32.0 wheel; do for whl in wheel==0.31.1 wheel==0.32.0 wheel; do
$pip_install -U $whl $pip_install -U $whl
...@@ -22,3 +25,35 @@ if [ $lpv -ge $(lex_ver 3.5) ] || [ $lpv -lt $(lex_ver 3) ]; then ...@@ -22,3 +25,35 @@ if [ $lpv -ge $(lex_ver 3.5) ] || [ $lpv -lt $(lex_ver 3) ]; then
texext-0.6.1-cp36-none-any.whl texext-0.6.1-cp36-none-any.whl
done done
fi fi
# Test that wheels for versions other than our own, not supported.
py_impl=$($PYTHON_EXE -c 'import platform; print(platform.python_implementation())')
if [ "$py_impl" == 'CPython' ] && [ $(uname) == 'Darwin' ]; then
our_ver=$($PYTHON_EXE -c 'import sys; print("{}{}".format(*sys.version_info[:2]))')
other_ver=$([ "$our_ver" == "37" ] && echo "36" || echo "37")
# Python <= 3.7 needs m for API tag.
api_m=$([ $our_ver -le 37 ] && echo "m") || :
whl_suff="cp${our_ver}-cp${our_ver}${api_m}-macosx_10_9_x86_64.whl"
good_whl="tornado-5.1-${whl_suff}"
bad_whl="tornado-5.1-cp${other_ver}-cp${other_ver}m-macosx_10_9_x86_64.whl"
if [ "$($PYTHON_EXE supported_wheels.py $bad_whl)" != "" ]; then
echo "$bad_whl not supported, but supported wheels says it is."
RET=1
fi
if [ "$($PYTHON_EXE supported_wheels.py $good_whl)" != "$good_whl" ]; then
echo "$good_whl supported, but supported wheels says it is not."
RET=1
fi
good_whl2="mypkg-0.3-${whl_suff}"
both="$good_whl
$good_whl2"
if [ "$($PYTHON_EXE supported_wheels.py $good_whl $good_whl2)" != "$both" ]; then
echo "$good_whl, $good_whl2 supported, supported_wheels does not return both."
RET=1
fi
if [ "$($PYTHON_EXE supported_wheels.py $good_whl $bad_whl $good_whl2)" != "$both" ]; then
echo "$good_whl, $good_whl2 supported, $bad_whl not; supported_wheels disagrees."
RET=1
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment