本文共 2816 字,大约阅读时间需要 9 分钟。
本文翻译自:
Two options in setup.py develop
and install
are confusing me. setup.py develop
和install
中的两个选项使我感到困惑。 According to this , using develop
creates a special link to site-packages directory. 根据此 ,使用develop
创建到site-packages目录的特殊链接。
People have suggested that I use python setup.py install
for a fresh installation and python setup.py develop
after any changes have been made to the setup file. 人们建议我将python setup.py install
用于全新安装,并对设置文件进行任何更改后再使用python setup.py develop
。
Can anyone shed some light on the usage of these commands? 任何人都可以阐明这些命令的用法吗?
参考:
python setup.py install
is used to install (typically third party) packages that you're not going to develop/modify/debug yourself. python setup.py install
用于安装(通常是第三方)您不会自行开发/修改/调试的软件包。
For your own stuff, you want to first install your package and then be able to frequently edit the code without having to re-install the package every time — and that is exactly what python setup.py develop
does: it installs the package (typically just a source folder) in a way that allows you to conveniently edit your code after it's installed to the (virtual) environment, and have the changes take effect immediately. 对于您自己的东西,您想先安装您的软件包,然后能够频繁编辑代码而不必每次都重新安装软件包-这正是python setup.py develop
所做的:它会安装软件包(通常是安装软件包只是一个源文件夹),从而可以在将代码安装到(虚拟)环境后方便地编辑代码,并使更改立即生效。
Note that it is highly recommended to use pip install .
请注意,强烈建议使用pip install .
(install) and pip install -e .
(安装)和pip install -e .
(developer install) to install packages, as invoking setup.py
directly will do the wrong things for many dependencies, such as pull prereleases and incompatible package versions, or make the package hard to uninstall with pip
. (开发人员安装)以安装软件包,因为直接调用setup.py
会对许多依赖项做错事,例如pull prereleases和不兼容的软件包版本,或者使软件包很难用pip
卸载。
From the . 从 。 The develop
will not install the package but it will create a .egg-link
in the deployment directory back to the project source code directory. develop
将不会安装软件包,但会在部署目录中创建一个.egg-link
,返回到项目源代码目录。
So it's like installing but instead of copying to the site-packages
it adds a symbolic link (the .egg-link
acts as a multiplatform symbolic link). 因此,这就像安装,而不是复制到site-packages
而是添加了符号链接( .egg-link
充当多平台符号链接)。
That way you can edit the source code and see the changes directly without having to reinstall every time that you make a little change. 这样,您可以编辑源代码并直接查看更改, 而无需在每次进行少量更改时都重新安装。 This is useful when you are the developer of that project hence the name develop
. 当您是该项目的开发者时,这很有用,因此名称为develop
。 If you are just installing someone else's package you should use install
如果您只是在安装别人的软件包,则应使用install
Another thing that people may find useful when using the develop
method is the --user
option to install without sudo. 人们使用develop
方法时可能会发现有用的另一件事是--user
选项,无需使用sudo即可安装。 Ex: 例如:
python setup.py develop --user
instead of 代替
sudo python setup.py develop
转载地址:http://pgcnb.baihongyu.com/