Rework tests check all wheels produced against a reference list
Also, wrap the cibuildwheel call to make building env easier
This commit is contained in:
@@ -1,49 +1,22 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
|
||||||
|
project_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
project_dir = os.path.dirname(__file__)
|
|
||||||
|
|
||||||
# build the wheels
|
# build the wheels
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir])
|
utils.cibuildwheel_run(project_dir)
|
||||||
|
|
||||||
# check that every wheel is produced
|
# check that the expected wheels are produced
|
||||||
if utils.platform == 'linux':
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
assert glob('wheelhouse/*-cp27-cp27m-manylinux1_x86_64.whl')
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
assert glob('wheelhouse/*-cp27-cp27mu-manylinux1_x86_64.whl')
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
assert glob('wheelhouse/*-cp34-cp34m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-cp35m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-cp36m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-cp37m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp27-cp27m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp27-cp27mu-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp34-cp34m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-cp35m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-cp36m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-cp37m-manylinux1_i686.whl')
|
|
||||||
|
|
||||||
if utils.platform == 'windows':
|
|
||||||
assert glob('wheelhouse/*-cp27-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp34-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp27-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp34-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-win_amd64.whl')
|
|
||||||
|
|
||||||
if utils.platform == 'macos':
|
def test_build_identifiers():
|
||||||
assert glob('wheelhouse/*-cp27-*-macosx_10_6_intel.whl')
|
# check that the number of expected wheels matches the number of build
|
||||||
assert glob('wheelhouse/*-cp34-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-macosx_10_6_intel.whl')
|
|
||||||
|
|
||||||
# also check that the number of built wheels matches the number of build
|
|
||||||
# identifiers
|
# identifiers
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
assert len(expected_wheels) == len(build_identifiers)
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
project_dir = os.path.dirname(__file__)
|
project_dir = os.path.dirname(__file__)
|
||||||
# set up the environment
|
|
||||||
env = os.environ.copy()
|
# build and test the wheels
|
||||||
env.update({
|
utils.run_cibuildwheel(project_dir, add_env={
|
||||||
'CIBW_TEST_REQUIRES': 'nose',
|
'CIBW_TEST_REQUIRES': 'nose',
|
||||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||||
# mac/linux.
|
# mac/linux.
|
||||||
@@ -14,10 +13,7 @@ def test():
|
|||||||
'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
|
'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
|
||||||
})
|
})
|
||||||
|
|
||||||
# build & test the wheels
|
# also check that we got the right wheels
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
# also check that we got the right number of built wheels
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
project_dir = os.path.dirname(__file__)
|
project_dir = os.path.dirname(__file__)
|
||||||
# set up the environment
|
|
||||||
env = os.environ.copy()
|
# build the wheels
|
||||||
# write python version information to a temporary file, this is checked
|
utils.run_cibuildwheel(project_dir, add_env={
|
||||||
# in setup.py
|
# write python version information to a temporary file, this is
|
||||||
env.update({
|
# checked in setup.py
|
||||||
'CIBW_BEFORE_BUILD': '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonexecutable.txt', 'w').write(sys.executable)"''',
|
'CIBW_BEFORE_BUILD': '''python -c "import sys; open('/tmp/pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('/tmp/pythonexecutable.txt', 'w').write(sys.executable)"''',
|
||||||
'CIBW_BEFORE_BUILD_WINDOWS': '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonexecutable.txt', 'w').write(sys.executable)"''',
|
'CIBW_BEFORE_BUILD_WINDOWS': '''python -c "import sys; open('c:\\pythonversion.txt', 'w').write(sys.version)" && python -c "import sys; open('c:\\pythonexecutable.txt', 'w').write(sys.executable)"''',
|
||||||
})
|
})
|
||||||
|
|
||||||
# build the wheels
|
# also check that we got the right wheels
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
# check that we got the right number of built wheels
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
|
||||||
|
|||||||
@@ -1,50 +1,17 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
project_dir = os.path.dirname(__file__)
|
project_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
# set up the environment
|
# build the wheels
|
||||||
env = os.environ.copy()
|
utils.run_cibuildwheel(project_dir, add_env={
|
||||||
env.update({
|
|
||||||
'CIBW_BUILD': 'cp3?-*',
|
'CIBW_BUILD': 'cp3?-*',
|
||||||
'CIBW_SKIP': 'cp34-*',
|
'CIBW_SKIP': 'cp34-*',
|
||||||
})
|
})
|
||||||
|
|
||||||
# build the wheels
|
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
|
||||||
|
|
||||||
# check that we got the right wheels. There should be no 2.7 or 3.4.
|
# check that we got the right wheels. There should be no 2.7 or 3.4.
|
||||||
if utils.platform == 'linux':
|
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||||
assert not glob('wheelhouse/*-cp27-cp27m-manylinux1_x86_64.whl')
|
if ('-cp3' in w) and ('-cp34' not in w)]
|
||||||
assert not glob('wheelhouse/*-cp27-cp27mu-manylinux1_x86_64.whl')
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
assert not glob('wheelhouse/*-cp34-cp34m-manylinux1_x86_64.whl')
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
assert glob('wheelhouse/*-cp35-cp35m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-cp36m-manylinux1_x86_64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-cp37m-manylinux1_x86_64.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp27-cp27m-manylinux1_i686.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp27-cp27mu-manylinux1_i686.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp34-cp34m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-cp35m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-cp36m-manylinux1_i686.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-cp37m-manylinux1_i686.whl')
|
|
||||||
|
|
||||||
if utils.platform == 'windows':
|
|
||||||
assert not glob('wheelhouse/*-cp27-*-win32.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp34-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-win32.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-win32.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp27-*-win_amd64.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp34-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-win_amd64.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-win_amd64.whl')
|
|
||||||
|
|
||||||
if utils.platform == 'macos':
|
|
||||||
assert not glob('wheelhouse/*-cp27-*-macosx_10_6_intel.whl')
|
|
||||||
assert not glob('wheelhouse/*-cp34-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp35-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp36-*-macosx_10_6_intel.whl')
|
|
||||||
assert glob('wheelhouse/*-cp37-*-macosx_10_6_intel.whl')
|
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
project_dir = os.path.dirname(__file__)
|
project_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
# set up the environment
|
|
||||||
env = os.environ.copy()
|
|
||||||
# write some information into the CIBW_ENVIRONMENT, for expansion and
|
# write some information into the CIBW_ENVIRONMENT, for expansion and
|
||||||
# insertion into the environment by cibuildwheel. This is checked
|
# insertion into the environment by cibuildwheel. This is checked
|
||||||
# in setup.py
|
# in setup.py
|
||||||
env.update({
|
utils.run_cibuildwheel(project_dir, add_env={
|
||||||
'CIBW_ENVIRONMENT': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path''',
|
'CIBW_ENVIRONMENT': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path''',
|
||||||
'CIBW_ENVIRONMENT_WINDOWS': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
|
'CIBW_ENVIRONMENT_WINDOWS': '''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
|
||||||
})
|
})
|
||||||
|
|
||||||
# build the wheels
|
# also check that we got the right wheels built
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
# check that we got the right number of built wheels
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import subprocess, sys, os, pytest
|
import os, pytest
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
@@ -8,19 +7,12 @@ def test():
|
|||||||
if utils.platform != 'linux':
|
if utils.platform != 'linux':
|
||||||
pytest.skip('the docker test is only relevant to the linux build')
|
pytest.skip('the docker test is only relevant to the linux build')
|
||||||
|
|
||||||
# set up the environment
|
utils.run_cibuildwheel(project_dir, add_env={
|
||||||
env = os.environ.copy()
|
|
||||||
# change the docker images to use. The docker image is tested in setup.py
|
|
||||||
# during the build
|
|
||||||
env.update({
|
|
||||||
'CIBW_MANYLINUX1_X86_64_IMAGE': 'dockcross/manylinux-x64',
|
'CIBW_MANYLINUX1_X86_64_IMAGE': 'dockcross/manylinux-x64',
|
||||||
'CIBW_MANYLINUX1_I686_IMAGE': 'dockcross/manylinux-x86',
|
'CIBW_MANYLINUX1_I686_IMAGE': 'dockcross/manylinux-x86',
|
||||||
})
|
})
|
||||||
|
|
||||||
# build the wheels
|
# also check that we got the right wheels built
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||||
|
actual_wheels = os.listdir('wheelhouse')
|
||||||
# check that we got the right number of built wheels
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import subprocess, sys, os
|
import os
|
||||||
from glob import glob
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
@@ -7,10 +6,4 @@ def test():
|
|||||||
# this test checks that SSL is working in the build environment using
|
# this test checks that SSL is working in the build environment using
|
||||||
# some checks in setup.py.
|
# some checks in setup.py.
|
||||||
|
|
||||||
# build the wheels
|
utils.cibuildwheel_run(project_dir)
|
||||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir])
|
|
||||||
|
|
||||||
# check that we got the right number of built wheels
|
|
||||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
|
||||||
built_wheels = glob('wheelhouse/*.whl')
|
|
||||||
assert len(built_wheels) == len(expected_identifiers)
|
|
||||||
|
|||||||
+71
-2
@@ -4,7 +4,8 @@ Utility functions used by the cibuildwheel tests.
|
|||||||
This file is added to the PYTHONPATH in the test runner at bin/run_test.py.
|
This file is added to the PYTHONPATH in the test runner at bin/run_test.py.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import subprocess, sys
|
import subprocess, sys, os
|
||||||
|
|
||||||
|
|
||||||
def cibuildwheel_get_build_identifiers(project_path, env=None):
|
def cibuildwheel_get_build_identifiers(project_path, env=None):
|
||||||
'''
|
'''
|
||||||
@@ -19,9 +20,77 @@ def cibuildwheel_get_build_identifiers(project_path, env=None):
|
|||||||
|
|
||||||
return cmd_output.strip().split('\n')
|
return cmd_output.strip().split('\n')
|
||||||
|
|
||||||
|
|
||||||
|
def cibuildwheel_run(project_path, env=None, add_env=None):
|
||||||
|
'''
|
||||||
|
Runs cibuildwheel as a subprocess, building the project at project_path.
|
||||||
|
|
||||||
|
Uses the current Python interpreter.
|
||||||
|
Configure settings using env.
|
||||||
|
'''
|
||||||
|
if env is None:
|
||||||
|
env = os.environ.copy()
|
||||||
|
|
||||||
|
if add_env is not None:
|
||||||
|
env.update(add_env)
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
[sys.executable, '-m', 'cibuildwheel', project_path],
|
||||||
|
env=env,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def expected_wheels(package_name, package_version):
|
||||||
|
'''
|
||||||
|
Returns a list of expected wheels from a run of cibuildwheel.
|
||||||
|
'''
|
||||||
|
if platform == 'linux':
|
||||||
|
templates = [
|
||||||
|
'{package_name}-{package_version}-cp27-cp27m-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp27-cp27mu-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp34-cp34m-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp35-cp35m-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp36-cp36m-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp37-cp37m-manylinux1_x86_64.whl',
|
||||||
|
'{package_name}-{package_version}-cp27-cp27m-manylinux1_i686.whl',
|
||||||
|
'{package_name}-{package_version}-cp27-cp27mu-manylinux1_i686.whl',
|
||||||
|
'{package_name}-{package_version}-cp34-cp34m-manylinux1_i686.whl',
|
||||||
|
'{package_name}-{package_version}-cp35-cp35m-manylinux1_i686.whl',
|
||||||
|
'{package_name}-{package_version}-cp36-cp36m-manylinux1_i686.whl',
|
||||||
|
'{package_name}-{package_version}-cp37-cp37m-manylinux1_i686.whl',
|
||||||
|
]
|
||||||
|
elif platform == 'windows':
|
||||||
|
templates = [
|
||||||
|
'{package_name}-{package_version}-cp27-cp27m-win32.whl',
|
||||||
|
'{package_name}-{package_version}-cp34-cp34m-win32.whl',
|
||||||
|
'{package_name}-{package_version}-cp35-cp35m-win32.whl',
|
||||||
|
'{package_name}-{package_version}-cp36-cp36m-win32.whl',
|
||||||
|
'{package_name}-{package_version}-cp37-cp37m-win32.whl',
|
||||||
|
'{package_name}-{package_version}-cp27-cp27m-win_amd64.whl',
|
||||||
|
'{package_name}-{package_version}-cp34-cp34m-win_amd64.whl',
|
||||||
|
'{package_name}-{package_version}-cp35-cp35m-win_amd64.whl',
|
||||||
|
'{package_name}-{package_version}-cp36-cp36m-win_amd64.whl',
|
||||||
|
'{package_name}-{package_version}-cp37-cp37m-win_amd64.whl',
|
||||||
|
]
|
||||||
|
elif platform == 'macos':
|
||||||
|
templates = [
|
||||||
|
'{package_name}-{package_version}-cp27-cp27m-macosx_10_6_intel.whl',
|
||||||
|
'{package_name}-{package_version}-cp34-cp34m-macosx_10_6_intel.whl',
|
||||||
|
'{package_name}-{package_version}-cp35-cp35m-macosx_10_6_intel.whl',
|
||||||
|
'{package_name}-{package_version}-cp36-cp36m-macosx_10_6_intel.whl',
|
||||||
|
'{package_name}-{package_version}-cp37-cp37m-macosx_10_6_intel.whl',
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
raise Exception('unsupported platform')
|
||||||
|
|
||||||
|
return [filename.format(package_name=package_name, package_version=package_version)
|
||||||
|
for filename in templates]
|
||||||
|
|
||||||
platform = None
|
platform = None
|
||||||
|
|
||||||
if sys.platform.startswith('linux'):
|
if 'CIBW_PLATFORM' in os.environ:
|
||||||
|
platform = os.environ['CIBW_PLATFORM']
|
||||||
|
elif sys.platform.startswith('linux'):
|
||||||
platform = 'linux'
|
platform = 'linux'
|
||||||
elif sys.platform.startswith('darwin'):
|
elif sys.platform.startswith('darwin'):
|
||||||
platform = 'macos'
|
platform = 'macos'
|
||||||
|
|||||||
Reference in New Issue
Block a user