diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 1a157495..2a3d6610 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -76,6 +76,8 @@ def main(): before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform) skip_config = os.environ.get('CIBW_SKIP', '') environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform) or '' + manylinux1_x86_64_image = os.environ.get('CIBW_MANYLINUX1_X86_64_IMAGE', None) + manylinux1_i686_image = os.environ.get('CIBW_MANYLINUX1_I686_IMAGE', None) try: environment = parse_environment(environment_config) @@ -128,7 +130,7 @@ def main(): os.makedirs(output_dir) if platform == 'linux': - cibuildwheel.linux.build(**build_options) + cibuildwheel.linux.build(manylinux1_x86_64_image=manylinux1_x86_64_image, manylinux1_i686_image=manylinux1_i686_image, **build_options) elif platform == 'windows': cibuildwheel.windows.build(**build_options) elif platform == 'macos': diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 68b0349e..5525f0d8 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -9,7 +9,7 @@ except ImportError: from pipes import quote as shlex_quote -def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment): +def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment, manylinux1_x86_64_image, manylinux1_i686_image): try: subprocess.check_call(['docker', '--version']) except: @@ -38,8 +38,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be python_configurations = [c for c in python_configurations if not skip(c.identifier)] platforms = [ - ('manylinux1_x86_64', 'quay.io/pypa/manylinux1_x86_64'), - ('manylinux1_i686', 'quay.io/pypa/manylinux1_i686'), + ('manylinux1_x86_64', manylinux1_x86_64_image or 'quay.io/pypa/manylinux1_x86_64'), + ('manylinux1_i686', manylinux1_i686_image or 'quay.io/pypa/manylinux1_i686'), ] for platform_tag, docker_image in platforms: diff --git a/test/06_docker_images/environment.json b/test/06_docker_images/environment.json new file mode 100644 index 00000000..e5e73cc8 --- /dev/null +++ b/test/06_docker_images/environment.json @@ -0,0 +1,5 @@ +{ + "CIBW_MANYLINUX1_X86_64_IMAGE": "dockcross/manylinux-x64", + "CIBW_MANYLINUX1_I686_IMAGE": "dockcross/manylinux-x86", + "CIBW_SKIP": "*macos* *win*" +} diff --git a/test/06_docker_images/setup.py b/test/06_docker_images/setup.py new file mode 100644 index 00000000..48d7c00b --- /dev/null +++ b/test/06_docker_images/setup.py @@ -0,0 +1,12 @@ +import os + +from setuptools import setup, Extension + +if os.environ.get('CIBUILDWHEEL', '0') != '1': + raise Exception('CIBUILDWHEEL environment variable is not set to 1') + +setup( + name="spam", + ext_modules=[Extension('spam', sources=['spam.c'])], + version="0.1.0", +) diff --git a/test/06_docker_images/spam.c b/test/06_docker_images/spam.c new file mode 100644 index 00000000..d1ab0f22 --- /dev/null +++ b/test/06_docker_images/spam.c @@ -0,0 +1,48 @@ +#include + +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) +}