pip install 实际上做了什么?

what does pip install actually do?

这里是超级新手问题..

pip install 实际上做了什么?

假设 pypi 包是一个 tarball...

是否只下载 tar.gz、解压缩并 运行 setup.py?

它是否将下载的包添加到 site_packages 文件夹?

我想使用 pypiserver 创建一个 pip 可安装的 pkg,这样我的同事就可以轻松地下载我的 pkg,但我有点不确定除了实际的 .py 脚本之外到底要包含什么。

任何指导将不胜感激

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.

参见:https://packaging.python.org/tutorials/packaging-projects/

您通常不会手动创建源存档和 wheel,而是使用 setuptoolswheel 为您创建。

现在很多包都是轮子。使用 pip 安装这些轮子时,pip 将:

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

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