Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ def main():
)

if platform == 'linux':
manylinux1_x86_64_image = os.environ.get('CIBW_MANYLINUX1_X86_64_IMAGE', None)
manylinux1_i686_image = os.environ.get('CIBW_MANYLINUX1_I686_IMAGE', None)

build_options.update(
manylinux1_images={'x86_64': manylinux1_x86_64_image, 'i686': manylinux1_i686_image},
manylinux_images={'manylinux1_x86_64': os.environ.get('CIBW_MANYLINUX1_X86_64_IMAGE', None),
'manylinux1_i686': os.environ.get('CIBW_MANYLINUX1_I686_IMAGE', None),
'manylinux2010_x86_64': os.environ.get('CIBW_MANYLINUX2010_X86_64_IMAGE', None)},
)
elif platform == 'macos':
pass
Expand Down
19 changes: 14 additions & 5 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ def get_python_configurations(build_selector):
PythonConfiguration(identifier='cp35-manylinux1_i686', path='/opt/python/cp35-cp35m'),
PythonConfiguration(identifier='cp36-manylinux1_i686', path='/opt/python/cp36-cp36m'),
PythonConfiguration(identifier='cp37-manylinux1_i686', path='/opt/python/cp37-cp37m'),
PythonConfiguration(identifier='cp27-manylinux2010_x86_64', path='/opt/python/cp27-cp27m'),
PythonConfiguration(identifier='cp27-manylinux2010_x86_64', path='/opt/python/cp27-cp27mu'),
PythonConfiguration(identifier='cp34-manylinux2010_x86_64', path='/opt/python/cp34-cp34m'),
PythonConfiguration(identifier='cp35-manylinux2010_x86_64', path='/opt/python/cp35-cp35m'),
PythonConfiguration(identifier='cp36-manylinux2010_x86_64', path='/opt/python/cp36-cp36m'),
PythonConfiguration(identifier='cp37-manylinux2010_x86_64', path='/opt/python/cp37-cp37m'),
]

# skip builds as required
return [c for c in python_configurations if build_selector(c.identifier)]


def build(project_dir, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment, manylinux1_images):
def build(project_dir, output_dir, test_command, test_requires, before_build, build_verbosity, build_selector, environment, manylinux_images):
try:
subprocess.check_call(['docker', '--version'])
except:
Expand All @@ -42,8 +48,9 @@ def build(project_dir, output_dir, test_command, test_requires, before_build, bu

python_configurations = get_python_configurations(build_selector)
platforms = [
('manylinux1_x86_64', manylinux1_images.get('x86_64') or 'quay.io/pypa/manylinux1_x86_64'),
('manylinux1_i686', manylinux1_images.get('i686') or 'quay.io/pypa/manylinux1_i686'),
('manylinux1_x86_64', manylinux_images.get('manylinux1_x86_64') or 'quay.io/pypa/manylinux1_x86_64'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these default images be here, or should they actually be in main.py?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joerick This is about the code style, rather than platform/ABI-related. Any preferences, here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joerick Thus linor code organizational detail is still open, as well.

('manylinux1_i686', manylinux_images.get('manylinux1_i686') or 'quay.io/pypa/manylinux1_i686'),
('manylinux2010_x86_64', manylinux_images.get('manylinux2010_x86_64') or 'quay.io/pypa/manylinux2010_x86_64'),
]

for platform_tag, docker_image in platforms:
Expand Down Expand Up @@ -80,10 +87,11 @@ def build(project_dir, output_dir, test_command, test_requires, before_build, bu
if [[ "$built_wheel" == *none-any.whl ]]; then
# pure python wheel - just copy
mv "$built_wheel" /tmp/delocated_wheel
delocated_wheel=(/tmp/delocated_wheel/*.whl)
else
auditwheel repair "$built_wheel" -w /tmp/delocated_wheel
auditwheel repair --plat {platform_tag} "$built_wheel" -w /tmp/delocated_wheel
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayeut I saw your PR pypa/manylinux#293 adding AUDITWHEEL_PLAT was merged. Do you suggest removing the --plat flag (being simpler), or do you advise keeping it here?

delocated_wheel=(/tmp/delocated_wheel/*-{platform_tag}.whl)
fi
delocated_wheel=(/tmp/delocated_wheel/*.whl)

# Install the wheel we just built
"$PYBIN/pip" install "$delocated_wheel"
Expand Down Expand Up @@ -115,6 +123,7 @@ def build(project_dir, output_dir, test_command, test_requires, before_build, bu
),
build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(build_verbosity)),
environment_exports='\n'.join(environment.as_shell_commands()),
platform_tag=platform_tag,
uid=os.getuid(),
gid=os.getgid(),
)
Expand Down
7 changes: 4 additions & 3 deletions test/06_docker_images/cibuildwheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ def test():
pytest.skip('the docker test is only relevant to the linux build')

utils.cibuildwheel_run(project_dir, add_env={
'CIBW_MANYLINUX1_X86_64_IMAGE': 'dockcross/manylinux-x64',
'CIBW_MANYLINUX1_I686_IMAGE': 'dockcross/manylinux-x86',
'CIBW_MANYLINUX1_X86_64_IMAGE': 'dockcross/manylinux1-x64',
'CIBW_MANYLINUX1_I686_IMAGE': 'dockcross/manylinux1-x86',
'CIBW_MANYLINUX2010_X86_64_IMAGE': 'dockcross/manylinux2010-x64',
})

# also check that we got the right wheels built
expected_wheels = utils.expected_wheels('spam', '0.1.0')
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')]
actual_wheels = os.listdir('wheelhouse')
assert set(actual_wheels) == set(expected_wheels)
22 changes: 22 additions & 0 deletions test/08_manylinux2010_only/cibuildwheel_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os, pytest
import utils

def test():
project_dir = os.path.dirname(__file__)

if utils.platform != 'linux':
pytest.skip('the docker test is only relevant to the linux build')

# build the wheels
# CFLAGS environment veriable is ecessary to fail on 'malloc_info' (on manylinux1) during compilation/linking,
# rather than when dynamically loading the Python
utils.cibuildwheel_run(project_dir, add_env={
'CIBW_ENVIRONMENT': 'CFLAGS="$CFLAGS -Werror=implicit-function-declaration"',
'CIBW_SKIP': '*-manylinux1_*',
})

# also check that we got the right wheels
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
if '-manylinux1_' not in w]
actual_wheels = os.listdir('wheelhouse')
assert set(actual_wheels) == set(expected_wheels)
7 changes: 7 additions & 0 deletions test/08_manylinux2010_only/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",
)
57 changes: 57 additions & 0 deletions test/08_manylinux2010_only/spam.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <Python.h>
#if defined(__linux__)
#include <malloc.h>
#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)
}
6 changes: 6 additions & 0 deletions test/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def expected_wheels(package_name, package_version):
'{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',
'{package_name}-{package_version}-cp27-cp27m-manylinux2010_x86_64.whl',
'{package_name}-{package_version}-cp27-cp27mu-manylinux2010_x86_64.whl',
'{package_name}-{package_version}-cp34-cp34m-manylinux2010_x86_64.whl',
'{package_name}-{package_version}-cp35-cp35m-manylinux2010_x86_64.whl',
'{package_name}-{package_version}-cp36-cp36m-manylinux2010_x86_64.whl',
'{package_name}-{package_version}-cp37-cp37m-manylinux2010_x86_64.whl',
]
elif platform == 'windows':
templates = [
Expand Down