Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Wheels on linux (how? and why?)

I know that wheels are binary version of a module uploaded on PyPI.

with pip install

  • On Windows: I get wheels downloaded and installed.
  • On Ubuntu: I should get the source distribution of the package BUT in some cases I get wheels.
  • On fedora: Tricky I have to install with dnf

I tried to add wheels to my package as well. But I am only able to upload wheels for windows.

  • Why do some packages provide wheels for Linux platform?
  • Is this okay? Providing binaries instead of the source?
  • Why I cannot provide wheels?

Note: I know a bit about Fedora rpm packages. I am interested now in wheels on Ubuntu.

like image 652
Szabolcs Dombi Avatar asked Jul 12 '16 09:07

Szabolcs Dombi


People also ask

What do Python wheels do?

Wheels are a component of the Python ecosystem that helps to make package installs just work. They allow for faster installations and more stability in the package distribution process.

Why are Python wheels called wheels?

PyPI used to be called a cheeseshop, in reference to a Monty Python sketch (where the cheeseshop has no cheese). The joke was that PyPI was initially like that - it had nothing in it back then. Based off that, wheel is a reference to wheels of cheese.


1 Answers

Why do some packages provide wheels for Linux platform?

Why shouldn't they, as long as source distributions are available as well? :)

Your question is not clear. If you meant

Why do some packages provide platform-specific wheels for Linux platform instead of platfom-independent ones?

then take a look at this question and its answers. If not, please clarify your question.


On Ubuntu: I should get the source distribution of the package BUT in some cases I get wheels.

Try using:

pip install --no-binary :all: somepackage

This should make pip download a source distribution if it exists on PyPI. I don't know why there are no source packages for PyQt5 on PyPI, probably because they are not installable with pip and need a whole toolchaing for compilation.


Is this okay? Providing binaries instead of the source?

It's okay as long as you provide both binaries and the source. I suggest you doing so.


Why I cannot provide wheels?

Try python setup.py bdist_wheel. You need to install wheel package (on PyPI) to make it work. If your package supports both Python 2 and 3 and contains no C extensions, append the --universal option to make a "universal wheel".

Replace bdist_wheel with sdist to make a source distribution. It will create an archive in dist directory.

sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

You can specify as many formats as you like using the --formats option, for example:

python setup.py sdist --formats=gztar,zip

to create a gzipped tarball and a zip file

(Quote from https://docs.python.org/3/distutils/sourcedist.html)


More info about packaging and wheels is available here: https://packaging.python.org/distributing/#packaging-your-project

like image 136
selurvedu Avatar answered Oct 04 '22 05:10

selurvedu