What does pip install actually do when handling a .tar.gz package?

Question:

What does pip install actually do assuming the pypi package is a tarball.

Does it just download the tar.gz, unpack it and run setup.py?

Does it add the downloaded package to the site_packages folder?

I want to create a pip installable package using pypiserver so my colleagues can download my package in a painless way, but am a little unsure exactly what to include beyond the actual .py scripts.

Asked By: Derek Eden

||

Answers:

The tar.gz file is a source archive whereas the .whl file is a built
distribution. Newer pip versions preferentially install built
distributions, but will fall back to source archives if needed. You
should always upload a source archive and provide built archives for
the platforms your project is compatible with. In this case, our
example package is compatible with Python on any platform so only one
built distribution is needed.

See: https://packaging.python.org/tutorials/packaging-projects/

You would typically not manually create the source archive and wheel, but use setuptools and wheel to do so for you.

Nowadays, many packages are wheels. While installing these wheels using pip, pip will:

[…] unpack the archive in your current site packages directory and install any console scripts contained in the wheel.

See: https://wheel.readthedocs.io/en/stable/user_guide.html#installing-wheels

Answered By: dkreeft
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.