为什么从git repo进行pip安装时#egg = foo

问题:为什么从git repo进行pip安装时#egg = foo

当我执行“ pip install -e …”以从git repo安装时,我必须指定#egg = somename或pip抱怨。例如:

pip install -e git://github.com/hiidef/oauth2app.git#egg=oauth2app

这个“蛋”字符串的意义是什么?

When I do a “pip install -e …” to install from a git repo, I have to specify #egg=somename or pip complains. For example:

pip install -e git://github.com/hiidef/oauth2app.git#egg=oauth2app

What’s the significance of this “egg” string?


回答 0

每点安装-h“ egg”字符串是在安装过程中检出的目录

per pip install -h the “egg” string is the directory that gets checked out as part of the install


回答 1

您必须包含#egg = Package,这样pip才能知道该URL的期望值。参见https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support

更多鸡蛋

You have to include #egg=Package so pip knows what to expect at that URL. See https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support

more on eggs


回答 2

https://pip.pypa.io/zh_CN/stable/reference/pip_install/#vcs-support说:

pip使用其URL后缀“ egg =-”的“项目名称”组件的依赖关系逻辑在pip下载和分析元数据之前识别项目。蛋名称的可选“版本”组件在功能上并不重要。它仅提供有关使用哪个版本的信息。对于setup.py不在项目根目录中的项目,将使用“子目录”组件。“子目录”组件的值应该是从项目根目录到setup.py所在位置的路径。

据此,我推断出egg值仅用于依赖性检查,因此,我认为按照惯例,some-pypi-package-name应使用包名称(即),而不要使用任何包含的文件夹(即some_pypi_package_name

https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support says:

The “project name” component of the url suffix “egg=-” is used by pip in its dependency logic to identify the project prior to pip downloading and analyzing the metadata. The optional “version” component of the egg name is not functionally important. It merely provides a human-readable clue as to what version is in use. For projects where setup.py is not in the root of project, “subdirectory” component is used. Value of “subdirectory” component should be a path starting from root of the project to where setup.py is located.

From this I deduce that the egg value is only used for dependency checks and therefore I think, by convention, the package name (i.e. some-pypi-package-name) should be used, not any contained folder (i.e. some_pypi_package_name)


回答 3

一个Egg只是一些捆绑的python代码。在git网址中,egg是项目名称。 VCS支持

通常,我们从Pypi安装python软件包,因此您仅指定软件包名称和版本(如果未指定,则假定为最新版本)。然后,Pypi搜索您想要的鸡蛋,然后pip安装该鸡蛋。 pip install celery将安装最新发布的鸡蛋,pip install celery[redis]并安装包含相同celery软件包的其他鸡蛋,并从celery的setup.py中列出为Redis依赖项的软件包中安装最新的鸡蛋。

使用git和gitlab路径,您可以指定/{user|group}/{repository}.git@{tag}#egg={package-name}#egg=celery和之间有区别#egg=celery[redis],但是它们都将来自同一源代码。

除实际标签外,“标签”还可以是分支或提交哈希。master如果未指定,则假定为。

例如,git+https://github.com/celery/celery.git#egg=celery==4.3.0将检出master分支并进行安装。即使您指定了版本号,在安装中也不会考虑。版本号被忽略

通过git或其他VCS网址进行安装时,您将需要查找所需版本的标签或哈希。例如,git+https://github.com/celery/celery.git@v4.3.0#egg=celery它将签出标记为“ v4.3.0”的提交,然后从该源代码安装该软件包。假设维护人员没有过分地错误标记他们的存储库,则可以得到所需的版本。

An Egg is just some bundled python code. In a git url, the egg is the project name. VCS Support

Normally we install python packages from Pypi, so you specify ONLY the package name and version (or it assumes latest version if you don’t specify). Pypi then searches for which egg you want and pip installs that. pip install celery would install the latest published egg and pip install celery[redis] would install a different egg that contains the same celery package and also installs the the latest eggs from whatever packages were listed as dependencies for redis in celery’s setup.py.

With git and gitlab paths, you specify /{user|group}/{repository}.git@{tag}#egg={package-name}. there is a difference between #egg=celery and #egg=celery[redis], but they will both come from the same source code.

“tag” can also be a branch or commit hash in addition to an actual tag. It is assumed to be master if you do not specify.

for example, git+https://github.com/celery/celery.git#egg=celery==4.3.0 would check out the master branch and install that. Even though you specified a version number, it is not taken into account in the installation. THE VERSION NUMBER IS IGNORED

When installing via git or other VCS urls, you will want to find the tag or hash of the version you need. For example, git+https://github.com/celery/celery.git@v4.3.0#egg=celery which will checkout the commit tagged “v4.3.0” and then install the package from that source code. Assuming the maintainers did not egregiously mis-tag their repositories, you can get the version you want like that.