sheshkovsky
sheshkovsky

Reputation: 1340

Can I create wheels for python packages on macOS usable for a ubuntu docker image?

I'm working on a python/django project. For deployment I want to create a ubuntu 16.04 docker image. When I'm working on a ubuntu local host, I generate all wheel files and they can be used to create image. ( I copy all of these wheels to docker, so I run RUN pip3 install --no-cache-dir --no-index -f wheelhouse -r requirements.txt in Dockerfile to install requirements using local wheels. where wheelehouse is a folder that I've copied all of my local wheels to it. )

But when I create wheels on macOS host, some generated wheels are something like some_packagename-**macosx_10_6_intel**.whl . So they're not usable to create an ubuntu docker image.

Is there a way I can force pip wheel to generate wheels for linux and not from source files on macOS?

Upvotes: 3

Views: 3164

Answers (1)

Anthon
Anthon

Reputation: 76632

If you have no C extensions, then you should be able to do:

python setup.py bdist_wheel --universal 

to get a non-platform specific some_packagename-X.Y.Z-py2.py3-none-any.whl

If you have C extensions, you need to generate platform specific wheels.

The best way to do this is by using Docker (which on MacOS runs in a virtual machine) and the manylinux Docker containers to generate wheels for Python 2.7 and 3.4-3.7.

The generated wheels will install on many older versions of Linux, because of the way the manylinux containers are created. That is much better then starting your own Ubuntu XX.04 version (maybe in virtual machine) and not being able to install that on anything uses older compiler etc than your Ubuntu version does.

Upvotes: 1

Related Questions