Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert that build will fail if there is no configuration to build #179

Closed
wants to merge 8 commits into from
Closed
8 changes: 4 additions & 4 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand Down
2 changes: 2 additions & 0 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ 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 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']),
Expand Down
2 changes: 2 additions & 0 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ 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 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'

Expand Down
2 changes: 2 additions & 0 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ 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 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))
Expand Down
52 changes: 52 additions & 0 deletions test/09_platform_selector_problem/cibuildwheel_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pytest
import os
import sys
import subprocess
import utils


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:
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")
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,
universal_newlines=True
)

assert "Check 'CIBW_BUILD' and 'CIBW_SKIP' environment variables." 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,
universal_newlines=True
)

assert "Build identifiers with 'manylinux1' been deprecated. Replacing all occurences of"\
" 'manylinux1' by 'manylinux' in the option 'CIBW_BUILD'" in res.stderr
7 changes: 7 additions & 0 deletions test/09_platform_selector_problem/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from setuptools import setup, Extension

setup(
name="spam",
ext_modules=[Extension('spam', sources=['spam.c'])],
version="0.1.0",
)
48 changes: 48 additions & 0 deletions test/09_platform_selector_problem/spam.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <Python.h>

static PyObject *
spam_system(PyObject *self, PyObject *args)
{
const char *command;
int sts;

if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
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)
}
8 changes: 4 additions & 4 deletions test/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="wheelhouse"):
'''
Runs cibuildwheel as a subprocess, building the project at project_path.

Expand All @@ -36,10 +36,10 @@ def cibuildwheel_run(project_path, env=None, add_env=None):

if add_env is not None:
env.update(add_env)

subprocess.check_call(
[sys.executable, '-m', 'cibuildwheel', project_path],
env=env,
[sys.executable, '-m', 'cibuildwheel', "--output-dir", output_dir, project_path],
env=env
)


Expand Down