Search code examples
pythonpython-wheelpython-packaging

What is the point of built distributions for pure Python packages?


One can share Python as a source distribution (.tar.gz format) or as a built distribution (wheels format).

As I understand it, the point of built distributions is:

  • Save time: Compilation might be pretty time-consuming. We can do this once on the server and share it for many users.
  • Reduce requirements: The user does not have to have a compiler installed

However, those two arguments for bdist files seem not to hold for pure-python packages. Still, I see that natsort comes in both, a sdist and a bdist. Is there any advantage of sharing a pure-python package in bdist format?


Solution

  • From pythonwheels.com:

    Advantages of wheels

    1. Faster installation for pure Python and native C extension packages.
    2. Avoids arbitrary code execution for installation. (Avoids setup.py)
    3. Installation of a C extension does not require a compiler on Linux, Windows or macOS.
    4. Allows better caching for testing and continuous integration.
    5. Creates .pyc files as part of installation to ensure they match the Python interpreter used.
    6. More consistent installs across platforms and machines.

    So for me, I think the first and second points are most meaningful for a pure Python package. It's smaller, faster and also more secure.