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
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
|
||||
project_dir = os.path.dirname(__file__)
|
||||
|
||||
def test():
|
||||
project_dir = os.path.dirname(__file__)
|
||||
|
||||
# build the wheels
|
||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir])
|
||||
|
||||
# check that every wheel is produced
|
||||
if utils.platform == 'linux':
|
||||
assert glob('wheelhouse/*-cp27-cp27m-manylinux1_x86_64.whl')
|
||||
assert glob('wheelhouse/*-cp27-cp27mu-manylinux1_x86_64.whl')
|
||||
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')
|
||||
utils.cibuildwheel_run(project_dir)
|
||||
|
||||
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')
|
||||
# check that the expected wheels are produced
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
if utils.platform == 'macos':
|
||||
assert glob('wheelhouse/*-cp27-*-macosx_10_6_intel.whl')
|
||||
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
|
||||
def test_build_identifiers():
|
||||
# check that the number of expected wheels matches the number of build
|
||||
# identifiers
|
||||
expected_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
||||
built_wheels = glob('wheelhouse/*.whl')
|
||||
assert len(built_wheels) == len(expected_identifiers)
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
build_identifiers = utils.cibuildwheel_get_build_identifiers(project_dir)
|
||||
assert len(expected_wheels) == len(build_identifiers)
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import subprocess, sys, os
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
def test():
|
||||
project_dir = os.path.dirname(__file__)
|
||||
# set up the environment
|
||||
env = os.environ.copy()
|
||||
env.update({
|
||||
|
||||
# build and test the wheels
|
||||
utils.run_cibuildwheel(project_dir, add_env={
|
||||
'CIBW_TEST_REQUIRES': 'nose',
|
||||
# the 'false ||' bit is to ensure this command runs in a shell on
|
||||
# mac/linux.
|
||||
'CIBW_TEST_COMMAND': 'false || nosetests {project}/test',
|
||||
'CIBW_TEST_COMMAND_WINDOWS': 'nosetests {project}/test',
|
||||
})
|
||||
|
||||
# build & test the wheels
|
||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
||||
|
||||
# also 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)
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import subprocess, sys, os
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
def test():
|
||||
project_dir = os.path.dirname(__file__)
|
||||
# set up the environment
|
||||
env = os.environ.copy()
|
||||
# write python version information to a temporary file, this is checked
|
||||
# in setup.py
|
||||
env.update({
|
||||
|
||||
# build the wheels
|
||||
utils.run_cibuildwheel(project_dir, add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# 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_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
|
||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
||||
|
||||
# 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)
|
||||
# also check that we got the right wheels
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -1,50 +1,17 @@
|
||||
import subprocess, sys, os
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
def test():
|
||||
project_dir = os.path.dirname(__file__)
|
||||
|
||||
# set up the environment
|
||||
env = os.environ.copy()
|
||||
env.update({
|
||||
|
||||
# build the wheels
|
||||
utils.run_cibuildwheel(project_dir, add_env={
|
||||
'CIBW_BUILD': 'cp3?-*',
|
||||
'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.
|
||||
if utils.platform == 'linux':
|
||||
assert not glob('wheelhouse/*-cp27-cp27m-manylinux1_x86_64.whl')
|
||||
assert not glob('wheelhouse/*-cp27-cp27mu-manylinux1_x86_64.whl')
|
||||
assert not 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 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')
|
||||
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
|
||||
if ('-cp3' in w) and ('-cp34' not in w)]
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
import subprocess, sys, os
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
def test():
|
||||
project_dir = os.path.dirname(__file__)
|
||||
|
||||
# set up the environment
|
||||
env = os.environ.copy()
|
||||
|
||||
# write some information into the CIBW_ENVIRONMENT, for expansion and
|
||||
# insertion into the environment by cibuildwheel. This is checked
|
||||
# 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_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
|
||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
||||
|
||||
# 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)
|
||||
# also check that we got the right wheels built
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import subprocess, sys, os, pytest
|
||||
from glob import glob
|
||||
import os, pytest
|
||||
import utils
|
||||
|
||||
def test():
|
||||
@@ -8,19 +7,12 @@ def test():
|
||||
if utils.platform != 'linux':
|
||||
pytest.skip('the docker test is only relevant to the linux build')
|
||||
|
||||
# set up the environment
|
||||
env = os.environ.copy()
|
||||
# change the docker images to use. The docker image is tested in setup.py
|
||||
# during the build
|
||||
env.update({
|
||||
utils.run_cibuildwheel(project_dir, add_env={
|
||||
'CIBW_MANYLINUX1_X86_64_IMAGE': 'dockcross/manylinux-x64',
|
||||
'CIBW_MANYLINUX1_I686_IMAGE': 'dockcross/manylinux-x86',
|
||||
})
|
||||
|
||||
# build the wheels
|
||||
subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir], env=env)
|
||||
|
||||
# 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)
|
||||
# also check that we got the right wheels built
|
||||
expected_wheels = utils.expected_wheels('spam', '0.1.0')
|
||||
actual_wheels = os.listdir('wheelhouse')
|
||||
assert set(actual_wheels) == set(expected_wheels)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import subprocess, sys, os
|
||||
from glob import glob
|
||||
import os
|
||||
import utils
|
||||
|
||||
def test():
|
||||
@@ -7,10 +6,4 @@ def test():
|
||||
# this test checks that SSL is working in the build environment using
|
||||
# some checks in setup.py.
|
||||
|
||||
# build the wheels
|
||||
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)
|
||||
utils.cibuildwheel_run(project_dir)
|
||||
|
||||
+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.
|
||||
'''
|
||||
|
||||
import subprocess, sys
|
||||
import subprocess, sys, os
|
||||
|
||||
|
||||
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')
|
||||
|
||||
|
||||
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
|
||||
|
||||
if sys.platform.startswith('linux'):
|
||||
if 'CIBW_PLATFORM' in os.environ:
|
||||
platform = os.environ['CIBW_PLATFORM']
|
||||
elif sys.platform.startswith('linux'):
|
||||
platform = 'linux'
|
||||
elif sys.platform.startswith('darwin'):
|
||||
platform = 'macos'
|
||||
|
||||
Reference in New Issue
Block a user