From bbda204e2e8de0cf07a96ddb0662665bd27ca76a Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Fri, 25 Oct 2019 08:08:58 +0200 Subject: [PATCH 1/8] assert that build will fail if there is no configuration to build move debug information to stderr add tests which check if all information are correct --- .travis.yml | 7 +++ cibuildwheel/__main__.py | 8 +-- cibuildwheel/linux.py | 3 + cibuildwheel/macos.py | 3 + cibuildwheel/windows.py | 3 + .../cibuildwheel_test.py | 59 +++++++++++++++++++ test/09_platform_selector_problem/setup.py | 7 +++ test/09_platform_selector_problem/spam.c | 57 ++++++++++++++++++ 8 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 test/09_platform_selector_problem/cibuildwheel_test.py create mode 100644 test/09_platform_selector_problem/setup.py create mode 100644 test/09_platform_selector_problem/spam.c diff --git a/.travis.yml b/.travis.yml index 8ddfbf0c6..786ffd3d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,13 @@ matrix: services: docker env: PYTHON=python + # Linux Python 3 + - sudo: required + language: python + python: 3.5 + services: docker + env: PYTHON=python + # macOS Python 2 - os: osx env: PYTHON=python2 diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 67d908270..966976727 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -185,18 +185,18 @@ def detect_obsolete_options(): for (deprecated, alternative) in [('CIBW_MANYLINUX1_X86_64_IMAGE', 'CIBW_MANYLINUX_X86_64_IMAGE'), ('CIBW_MANYLINUX1_I686_IMAGE', 'CIBW_MANYLINUX_I686_IMAGE')]: if deprecated in os.environ: - print("'{}' has been deprecated, and will be removed in a future release. Use the option '{}' instead.".format(deprecated, alternative)) + print("'{}' has been deprecated, and will be removed in a future release. Use the option '{}' instead.".format(deprecated, alternative), file=sys.stderr) if alternative not in os.environ: - print("Using value of option '{}' as replacement for '{}'".format(deprecated, alternative)) + print("Using value of option '{}' as replacement for '{}'".format(deprecated, alternative), file=sys.stderr) os.environ[alternative] = os.environ[deprecated] else: - print("Option '{}' is not empty. Please unset '{}'".format(alternative, deprecated)) + print("Option '{}' is not empty. Please unset '{}'".format(alternative, deprecated), file=sys.stderr) exit(2) # Check for 'manylinux1' in the 'CIBW_BUILD' and 'CIBW_SKIP' options for deprecated in ['CIBW_BUILD', 'CIBW_SKIP']: if deprecated in os.environ and 'manylinux1' in os.environ[deprecated]: - print("Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'".format(deprecated)) + print("Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of 'manylinux1' by 'manylinux' in the option '{}'".format(deprecated), file=sys.stderr) os.environ[deprecated] = os.environ[deprecated].replace('manylinux1', 'manylinux') diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index ad666f45e..f08ce49aa 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -41,6 +41,9 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef exit(2) python_configurations = get_python_configurations(build_selector) + if len(python_configurations) == 0: + raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables. " \ + "Check documentation if python version identifier do not change") platforms = [ ('manylinux_x86_64', manylinux_images['x86_64']), ('manylinux_i686', manylinux_images['i686']), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 25bf78a7e..dc37fc924 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -27,6 +27,9 @@ def get_python_configurations(build_selector): def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, environment): python_configurations = get_python_configurations(build_selector) + if len(python_configurations) == 0: + raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables " \ + "Check documentation if python version identifier do not change") get_pip_url = 'https://bootstrap.pypa.io/get-pip.py' get_pip_script = '/tmp/get-pip.py' diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index d37d75097..3fb9e2f79 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -96,6 +96,9 @@ def shell(args, env=None, cwd=None): download('https://bootstrap.pypa.io/get-pip.py', get_pip_script) python_configurations = get_python_configurations(build_selector) + if len(python_configurations) == 0: + raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables " \ + "Check documentation if python version identifier do not change") for config in python_configurations: config_python_path = get_python_path(config) simple_shell([nuget, "install"] + get_nuget_args(config)) diff --git a/test/09_platform_selector_problem/cibuildwheel_test.py b/test/09_platform_selector_problem/cibuildwheel_test.py new file mode 100644 index 000000000..2327836cb --- /dev/null +++ b/test/09_platform_selector_problem/cibuildwheel_test.py @@ -0,0 +1,59 @@ +import pytest +import os +import sys +import subprocess +import utils + + +def test_wrong_identifier_py2_py34(): + if not (sys.version_info[0] == 2 or (sys.version_info[0] == 3 and sys.version_info[1] == 4)): + pytest.skip("test for python 2.7 and 3.4") + project_dir = os.path.dirname(__file__) + + with pytest.raises(subprocess.CalledProcessError) as excinfo: + utils.cibuildwheel_run(project_dir, add_env={'CIBW_BUILD':'py368-*'}) + +def test_wrong_identifier(): + if sys.version_info[0] == 2: + pytest.skip("test not running on python 2.7") + if sys.version_info[0] == 3 and sys.version_info[1] == 4: + pytest.skip("test not running on python 3.4") + project_dir = os.path.dirname(__file__) + env = os.environ.copy() + env['CIBW_BUILD'] = 'py368-*' + + with pytest.raises(subprocess.CalledProcessError) as excinfo: + subprocess.run( + [sys.executable, '-m', 'cibuildwheel', project_dir], + env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + if isinstance(excinfo.value.stderr, bytes): + assert "Empty list of configuration to build" in excinfo.value.stderr.decode() + else: + assert "Empty list of configuration to build" in excinfo.value.stderr + + + +def test_old_manylinux(): + if sys.version_info[0] == 2: + pytest.skip("test not running on python 2.7") + if sys.version_info[0] == 3 and sys.version_info[1] == 4: + pytest.skip("test not running on python 3.4") + if utils.platform != 'linux': + pytest.skip('the old manylinux test is only relevant to the linux build') + + project_dir = os.path.dirname(__file__) + + env = os.environ.copy() + env['CIBW_BUILD'] = "*-manylinux1_x86_64 py36-*" + + res = subprocess.run( + [sys.executable, '-m', 'cibuildwheel', project_dir], + env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + if isinstance(res.stderr, bytes): + assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ + " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr.decode() + else: + assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ + " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr \ No newline at end of file diff --git a/test/09_platform_selector_problem/setup.py b/test/09_platform_selector_problem/setup.py new file mode 100644 index 000000000..866fa22c0 --- /dev/null +++ b/test/09_platform_selector_problem/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup, Extension + +setup( + name="spam", + ext_modules=[Extension('spam', sources=['spam.c'])], + version="0.1.0", +) diff --git a/test/09_platform_selector_problem/spam.c b/test/09_platform_selector_problem/spam.c new file mode 100644 index 000000000..0e50eba9d --- /dev/null +++ b/test/09_platform_selector_problem/spam.c @@ -0,0 +1,57 @@ +#include +#if defined(__linux__) +#include +#endif + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts = 0; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + +#if defined(__linux__) + sts = malloc_info(0, stdout); +#endif + if (sts == 0) { + sts = system(command); + } + return PyLong_FromLong(sts); +} + +/* Module initialization */ + +#if PY_MAJOR_VERSION >= 3 + #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ + m = PyModule_Create(&moduledef); + #define MOD_RETURN(m) return m; +#else + #define MOD_INIT(name) PyMODINIT_FUNC init##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + m = Py_InitModule3(name, methods, doc); + #define MOD_RETURN(m) return; +#endif + +static PyMethodDef module_methods[] = { + {"system", (PyCFunction)spam_system, METH_VARARGS, + "Execute a shell command."}, + {NULL} /* Sentinel */ +}; + +MOD_INIT(spam) +{ + PyObject* m; + + MOD_DEF(m, + "spam", + "Example module", + module_methods, + -1) + + MOD_RETURN(m) +} From 3af48abab38411ddefe2c6c1455134e6f7af9f49 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 3 Nov 2019 02:19:22 +0100 Subject: [PATCH 2/8] use universal_newlines to get string instead of bytes --- .../cibuildwheel_test.py | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/09_platform_selector_problem/cibuildwheel_test.py b/test/09_platform_selector_problem/cibuildwheel_test.py index 2327836cb..dd78d5a03 100644 --- a/test/09_platform_selector_problem/cibuildwheel_test.py +++ b/test/09_platform_selector_problem/cibuildwheel_test.py @@ -25,12 +25,11 @@ def test_wrong_identifier(): with pytest.raises(subprocess.CalledProcessError) as excinfo: subprocess.run( [sys.executable, '-m', 'cibuildwheel', project_dir], - env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True ) - if isinstance(excinfo.value.stderr, bytes): - assert "Empty list of configuration to build" in excinfo.value.stderr.decode() - else: - assert "Empty list of configuration to build" in excinfo.value.stderr + + assert "Empty list of configuration to build" in excinfo.value.stderr @@ -49,11 +48,9 @@ def test_old_manylinux(): res = subprocess.run( [sys.executable, '-m', 'cibuildwheel', project_dir], - env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + env=env, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True ) - if isinstance(res.stderr, bytes): - assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ - " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr.decode() - else: - assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ - " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr \ No newline at end of file + + assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ + " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr \ No newline at end of file From a059f3afcb305fb509a6d2e196eab8fd6fda6ed3 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 3 Nov 2019 21:52:54 +0100 Subject: [PATCH 3/8] remove python 3.4 from travis matrix build --- .travis.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 786ffd3d2..8ddfbf0c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,13 +16,6 @@ matrix: services: docker env: PYTHON=python - # Linux Python 3 - - sudo: required - language: python - python: 3.5 - services: docker - env: PYTHON=python - # macOS Python 2 - os: osx env: PYTHON=python2 From f00f9d1c3d366670fa08c35bf0f0f137e3a9170a Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 4 Nov 2019 00:32:18 +0100 Subject: [PATCH 4/8] Change text of exception, replace test spam module for more generic --- cibuildwheel/linux.py | 2 +- cibuildwheel/macos.py | 2 +- cibuildwheel/windows.py | 2 +- .../cibuildwheel_test.py | 3 +-- test/09_platform_selector_problem/spam.c | 13 ++----------- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index f08ce49aa..65766a588 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -42,7 +42,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables. " \ + raise ValueError("No linux build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ "Check documentation if python version identifier do not change") platforms = [ ('manylinux_x86_64', manylinux_images['x86_64']), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index dc37fc924..f9eee0bee 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -28,7 +28,7 @@ def get_python_configurations(build_selector): def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, environment): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables " \ + raise ValueError("No macosx build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ "Check documentation if python version identifier do not change") get_pip_url = 'https://bootstrap.pypa.io/get-pip.py' get_pip_script = '/tmp/get-pip.py' diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 3fb9e2f79..e0e66ab66 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -97,7 +97,7 @@ def shell(args, env=None, cwd=None): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("Empty list of configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables " \ + raise ValueError("No windows build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ "Check documentation if python version identifier do not change") for config in python_configurations: config_python_path = get_python_path(config) diff --git a/test/09_platform_selector_problem/cibuildwheel_test.py b/test/09_platform_selector_problem/cibuildwheel_test.py index dd78d5a03..e2f176036 100644 --- a/test/09_platform_selector_problem/cibuildwheel_test.py +++ b/test/09_platform_selector_problem/cibuildwheel_test.py @@ -29,8 +29,7 @@ def test_wrong_identifier(): universal_newlines=True ) - assert "Empty list of configuration to build" in excinfo.value.stderr - + assert "build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'" in excinfo.value.stderr def test_old_manylinux(): diff --git a/test/09_platform_selector_problem/spam.c b/test/09_platform_selector_problem/spam.c index 0e50eba9d..d1ab0f225 100644 --- a/test/09_platform_selector_problem/spam.c +++ b/test/09_platform_selector_problem/spam.c @@ -1,23 +1,14 @@ #include -#if defined(__linux__) -#include -#endif static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; - int sts = 0; + int sts; if (!PyArg_ParseTuple(args, "s", &command)) return NULL; - -#if defined(__linux__) - sts = malloc_info(0, stdout); -#endif - if (sts == 0) { - sts = system(command); - } + sts = system(command); return PyLong_FromLong(sts); } From 26ad60e03b066aedc20e43697ee105438b77696c Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 4 Nov 2019 08:41:02 +0100 Subject: [PATCH 5/8] remove suggestion to check documentation. --- cibuildwheel/linux.py | 3 +-- cibuildwheel/macos.py | 3 +-- cibuildwheel/windows.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 65766a588..48cb25b2a 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -42,8 +42,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No linux build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ - "Check documentation if python version identifier do not change") + raise ValueError("No linux build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. ") platforms = [ ('manylinux_x86_64', manylinux_images['x86_64']), ('manylinux_i686', manylinux_images['i686']), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index f9eee0bee..13fbea9a2 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -28,8 +28,7 @@ def get_python_configurations(build_selector): def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, environment): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No macosx build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ - "Check documentation if python version identifier do not change") + raise ValueError("No macosx build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'.") get_pip_url = 'https://bootstrap.pypa.io/get-pip.py' get_pip_script = '/tmp/get-pip.py' diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index e0e66ab66..d6594885a 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -97,8 +97,7 @@ def shell(args, env=None, cwd=None): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No windows build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. " \ - "Check documentation if python version identifier do not change") + raise ValueError("No windows build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. ") for config in python_configurations: config_python_path = get_python_path(config) simple_shell([nuget, "install"] + get_nuget_args(config)) From 02b2fe47908e1d1eb35104f5aa26dd0331067367 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Tue, 5 Nov 2019 21:58:54 +0100 Subject: [PATCH 6/8] fail only in CIBW_BUILD match no python configuration --- cibuildwheel/linux.py | 4 +++- cibuildwheel/macos.py | 4 +++- cibuildwheel/util.py | 6 ++++++ cibuildwheel/windows.py | 4 +++- test/09_platform_selector_problem/cibuildwheel_test.py | 10 ++++++++-- test/shared/utils.py | 9 ++++++--- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 48cb25b2a..55cadd780 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -42,7 +42,9 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No linux build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. ") + positive_configuration = get_python_configurations(build_selector.positive_only()) + if len(positive_configuration) == 0: + raise ValueError("Empty list of linux configuration to build. Check 'CIBW_BUILD' environment variable.") platforms = [ ('manylinux_x86_64', manylinux_images['x86_64']), ('manylinux_i686', manylinux_images['i686']), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 13fbea9a2..487545740 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -28,7 +28,9 @@ def get_python_configurations(build_selector): def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, environment): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No macosx build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'.") + positive_configuration = get_python_configurations(build_selector.positive_only()) + if len(positive_configuration) == 0: + raise ValueError("Empty list of macosx configuration to build. Check 'CIBW_BUILD' environment variables") get_pip_url = 'https://bootstrap.pypa.io/get-pip.py' get_pip_script = '/tmp/get-pip.py' diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 160e8c205..df9e63459 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -34,6 +34,12 @@ def match_any(patterns): def __repr__(self): return 'BuildSelector({!r} - {!r})'.format(' '.join(self.build_patterns), ' '.join(self.skip_patterns)) + def positive_only(self): + """return BuildSelector with only build_pattern""" + build_selector = BuildSelector("", "") + build_selector.build_patterns = self.build_patterns[:] + return build_selector + # Taken from https://stackoverflow.com/a/107717 class Unbuffered(object): diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index d6594885a..5aed61e01 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -97,7 +97,9 @@ def shell(args, env=None, cwd=None): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - raise ValueError("No windows build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'. ") + positive_configuration = get_python_configurations(build_selector.positive_only()) + if len(positive_configuration) == 0: + raise ValueError("Empty list of windows configuration to build. Check 'CIBW_BUILD' environment variables") for config in python_configurations: config_python_path = get_python_path(config) simple_shell([nuget, "install"] + get_nuget_args(config)) diff --git a/test/09_platform_selector_problem/cibuildwheel_test.py b/test/09_platform_selector_problem/cibuildwheel_test.py index e2f176036..38bc7c462 100644 --- a/test/09_platform_selector_problem/cibuildwheel_test.py +++ b/test/09_platform_selector_problem/cibuildwheel_test.py @@ -29,7 +29,13 @@ def test_wrong_identifier(): universal_newlines=True ) - assert "build identifiers are selected after applying 'CIBW_BUILD' and 'CIBW_SKIP'" in excinfo.value.stderr + assert "configuration to build. Check 'CIBW_BUILD' environment variable" in excinfo.value.stderr + +def skip_all(tmp_path): + tmp_path = str(tmp_path) + project_dir = os.path.dirname(__file__) + utils.cibuildwheel_run(project_dir, add_env={'CIBW_SKIP':'*'}, output_dir=tmp_path) + assert len(os.listdir(tmp_path)) == 0 def test_old_manylinux(): @@ -52,4 +58,4 @@ def test_old_manylinux(): ) assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\ - " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr \ No newline at end of file + " 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr \ No newline at end of file diff --git a/test/shared/utils.py b/test/shared/utils.py index d4e9c9c62..aecbc6a55 100644 --- a/test/shared/utils.py +++ b/test/shared/utils.py @@ -24,7 +24,7 @@ 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): +def cibuildwheel_run(project_path, env=None, add_env=None, output_dir=None): ''' Runs cibuildwheel as a subprocess, building the project at project_path. @@ -36,10 +36,13 @@ def cibuildwheel_run(project_path, env=None, add_env=None): if add_env is not None: env.update(add_env) + + if output_dir is None: + output_dir = "wheelhouse" subprocess.check_call( - [sys.executable, '-m', 'cibuildwheel', project_path], - env=env, + [sys.executable, '-m', 'cibuildwheel', "--output-dir", output_dir, project_path], + env=env ) From 85068a3a0fb77c17854e1b17ad55e6604478e33d Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sat, 9 Nov 2019 23:18:05 +0100 Subject: [PATCH 7/8] fix python convention move cibuildwheel_run output_dir default value to signature --- test/shared/utils.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/shared/utils.py b/test/shared/utils.py index aecbc6a55..5b1890c99 100644 --- a/test/shared/utils.py +++ b/test/shared/utils.py @@ -24,7 +24,7 @@ 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, output_dir=None): +def cibuildwheel_run(project_path, env=None, add_env=None, output_dir="wheelhouse"): ''' Runs cibuildwheel as a subprocess, building the project at project_path. @@ -37,9 +37,6 @@ def cibuildwheel_run(project_path, env=None, add_env=None, output_dir=None): if add_env is not None: env.update(add_env) - if output_dir is None: - output_dir = "wheelhouse" - subprocess.check_call( [sys.executable, '-m', 'cibuildwheel', "--output-dir", output_dir, project_path], env=env From 99f831807aaf83d31a1249f5318f077ac455a543 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 11 Nov 2019 17:15:57 +0100 Subject: [PATCH 8/8] return to assumption to check empty list per system --- cibuildwheel/linux.py | 4 +--- cibuildwheel/macos.py | 4 +--- cibuildwheel/util.py | 6 ------ cibuildwheel/windows.py | 4 +--- .../cibuildwheel_test.py | 17 ++++------------- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 55cadd780..295a79456 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -42,9 +42,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - positive_configuration = get_python_configurations(build_selector.positive_only()) - if len(positive_configuration) == 0: - raise ValueError("Empty list of linux configuration to build. Check 'CIBW_BUILD' environment variable.") + raise ValueError("Empty list of linux configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables.") platforms = [ ('manylinux_x86_64', manylinux_images['x86_64']), ('manylinux_i686', manylinux_images['i686']), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 487545740..c3cc6268b 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -28,9 +28,7 @@ def get_python_configurations(build_selector): def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, environment): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - positive_configuration = get_python_configurations(build_selector.positive_only()) - if len(positive_configuration) == 0: - raise ValueError("Empty list of macosx configuration to build. Check 'CIBW_BUILD' environment variables") + raise ValueError("Empty list of macosx configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables.") get_pip_url = 'https://bootstrap.pypa.io/get-pip.py' get_pip_script = '/tmp/get-pip.py' diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index df9e63459..160e8c205 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -34,12 +34,6 @@ def match_any(patterns): def __repr__(self): return 'BuildSelector({!r} - {!r})'.format(' '.join(self.build_patterns), ' '.join(self.skip_patterns)) - def positive_only(self): - """return BuildSelector with only build_pattern""" - build_selector = BuildSelector("", "") - build_selector.build_patterns = self.build_patterns[:] - return build_selector - # Taken from https://stackoverflow.com/a/107717 class Unbuffered(object): diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 5aed61e01..0e80d56d0 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -97,9 +97,7 @@ def shell(args, env=None, cwd=None): python_configurations = get_python_configurations(build_selector) if len(python_configurations) == 0: - positive_configuration = get_python_configurations(build_selector.positive_only()) - if len(positive_configuration) == 0: - raise ValueError("Empty list of windows configuration to build. Check 'CIBW_BUILD' environment variables") + raise ValueError("Empty list of windows configuration to build. Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables.") for config in python_configurations: config_python_path = get_python_path(config) simple_shell([nuget, "install"] + get_nuget_args(config)) diff --git a/test/09_platform_selector_problem/cibuildwheel_test.py b/test/09_platform_selector_problem/cibuildwheel_test.py index 38bc7c462..a998a89e0 100644 --- a/test/09_platform_selector_problem/cibuildwheel_test.py +++ b/test/09_platform_selector_problem/cibuildwheel_test.py @@ -5,9 +5,9 @@ import utils -def test_wrong_identifier_py2_py34(): - if not (sys.version_info[0] == 2 or (sys.version_info[0] == 3 and sys.version_info[1] == 4)): - pytest.skip("test for python 2.7 and 3.4") +def test_wrong_identifier_py2(): + if sys.version_info[0] != 2: + pytest.skip("test for python 2.7") project_dir = os.path.dirname(__file__) with pytest.raises(subprocess.CalledProcessError) as excinfo: @@ -16,8 +16,6 @@ def test_wrong_identifier_py2_py34(): def test_wrong_identifier(): if sys.version_info[0] == 2: pytest.skip("test not running on python 2.7") - if sys.version_info[0] == 3 and sys.version_info[1] == 4: - pytest.skip("test not running on python 3.4") project_dir = os.path.dirname(__file__) env = os.environ.copy() env['CIBW_BUILD'] = 'py368-*' @@ -29,14 +27,7 @@ def test_wrong_identifier(): universal_newlines=True ) - assert "configuration to build. Check 'CIBW_BUILD' environment variable" in excinfo.value.stderr - -def skip_all(tmp_path): - tmp_path = str(tmp_path) - project_dir = os.path.dirname(__file__) - utils.cibuildwheel_run(project_dir, add_env={'CIBW_SKIP':'*'}, output_dir=tmp_path) - assert len(os.listdir(tmp_path)) == 0 - + assert "Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables." in excinfo.value.stderr def test_old_manylinux(): if sys.version_info[0] == 2: