pythontarpackagingpython-wheel

Python packaging: wheels vs tarball (tar.gz)


The advantage of wheels over eggs is clear (see section why not egg? https://pypi.python.org/pypi/wheel).

However, it is not entirely clear to me what is the advantage of using wheels over tar.gz. I might be missing something obvious like "they are the same". As I see it both can be installed directly using pip (even in Windows), have similar size and when packaging require a similar effort. It sounds to me like the kind of questions you might get when justifying a packaging methodology.

EDIT: Just found an example where tar.gz might be better than wheels. CherryPy (https://pypi.python.org/pypi/CherryPy) provides wheels for Python 3.x only, so if you want to have a local repository to serve CherryPy for Python 2.7 and 3.x dependencies, it seems to make more sense to store the tarball. Is this correct? (just to add a couple of "case-based" justification to the discussion)


Solution

  • This answered it for me (directly from the wheel PEP):

    Python needs a package format that is easier to install than sdist. Python's sdist packages are defined by and require the distutils and setuptools build systems, running arbitrary code to build-and-install, and re-compile, code just so it can be installed into a new virtualenv. This system of conflating build-install is slow, hard to maintain, and hinders innovation in both build systems and installers.

    Wheel attempts to remedy these problems by providing a simpler interface between the build system and the installer. The wheel binary package format frees installers from having to know about the build system, saves time by amortizing compile time over many installations, and removes the need to install a build system in the target environment.

    https://www.python.org/dev/peps/pep-0427/#rationale

    Note the tarballs we're speaking of are what are referred to as "sdists" above.