Python setup.py 开发与安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19048732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python setup.py develop vs install
提问by Netro
Two options in setup.py develop
and install
are confusing me. According to this site, using develop
creates a special link to site-packages directory.
在setup.py两个选项develop
,并install
混淆了我。根据此站点,使用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?
谁能解释一下这些命令的用法?
采纳答案by Erik Kaplun
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 withouthaving 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 .
(install) and 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
.
请注意,强烈建议使用pip install .
(install) 和pip install -e .
(developer install) 来安装软件包,因为setup.py
直接调用会对许多依赖项做错误的事情,例如拉取预发布和不兼容的软件包版本,或者使用pip
.
回答by RubenLaguna
From the documentation. 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 withouthaving 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
. If you are just installing someone else's package you should use install
这样您就可以编辑源代码并直接查看更改,而不必每次进行一点更改时都重新安装。当您是该项目的开发人员时,这很有用,因此得名develop
。如果你只是安装别人的包,你应该使用install
回答by Taylor
Another thing that people may find useful when using the develop
method is the --user
option to install without sudo. Ex:
人们在使用该develop
方法时可能会发现有用的另一件事是--user
无需 sudo 即可安装的选项。前任:
python setup.py develop --user
instead of
代替
sudo python setup.py develop