Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ 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:
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']),
Expand Down
4 changes: 4 additions & 0 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ 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")
get_pip_url = 'https://bootstrap.pypa.io/get-pip.py'
get_pip_script = '/tmp/get-pip.py'

Expand Down
6 changes: 6 additions & 0 deletions cibuildwheel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ 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:
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))
Expand Down
61 changes: 61 additions & 0 deletions test/09_platform_selector_problem/cibuildwheel_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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,
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


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)
}
9 changes: 6 additions & 3 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=None):
'''
Runs cibuildwheel as a subprocess, building the project at project_path.

Expand All @@ -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
)


Expand Down