使用 pip 或来自存储库的 easy_install 安装 Python 包
到目前为止,对我来说,处理 python 包安装的最简单方法是从源代码控制系统中检查源代码,然后在 python dist-packages 文件夹中添加符号链接。
显然,由于源代码管理提供了对降级、升级到任何分支、标签的完整控制,因此它工作得非常好。
有没有一种方法可以使用其中一个软件包安装程序(easy_install 或 pip 或其他)来实现相同的目的。
easy_install 获取 tar.gz 并使用 setup.py install 安装它们,该安装安装在 python2.6 的 dist-packages 文件夹中。 有没有办法配置它,或者 pip 使用源版本控制系统(SVN/GIT/Hg/Bzr)来代替。
The simplest way to deal with python package installations, so far, to me, has been to check out the source from the source control system and then add a symbolic link in the python dist-packages folder.
Clearly since source control provides the complete control to downgrade, upgrade to any branch, tag, it works very well.
Is there a way using one of the Package installers (easy_install or pip or other), one can achieve the same.
easy_install obtains the tar.gz and install them using the setup.py install which installs in the dist-packages folder in python2.6. Is there a way to configure it, or pip to use the source version control system (SVN/GIT/Hg/Bzr) instead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 pip 这非常简单。 例如:
Pip 将自动克隆源代码库并运行“setup.pydevelopment”,以便您将其安装到您的环境中(希望是 virtualenv)。 Git、Subversion、Bazaar 和 Mercurial 均受支持。
然后,您还可以运行“pip freeze”,它将输出当前安装的软件包及其确切版本的列表(包括,对于开发安装,来自 VCS 的确切修订版)。 您可以将其直接放入需求文件中,然后运行
以完全相同的版本安装同一组软件包。
Using pip this is quite easy. For instance:
Pip will automatically clone the source repo and run "setup.py develop" for you to install it into your environment (which hopefully is a virtualenv). Git, Subversion, Bazaar and Mercurial are all supported.
You can also then run "pip freeze" and it will output a list of your currently-installed packages with their exact versions (including, for develop-installs, the exact revision from the VCS). You can put this straight into a requirements file and later run
to install that same set of packages at the exact same versions.
如果您下载或查看软件包的源代码分发版(其中包含“setup.py”),那么如果该软件包基于“setuptools”(它也为 easy_install 提供动力),您可以进入该软件包目录并说:
它将在 dist-packages 中创建正确的符号链接,以便源发行版中的 .py 文件被导入,而不是单独安装的副本(这就是“setup.py install”所做的 -创建单独的副本,当您编辑源代码以尝试更改时,这些副本不会立即更改)。
正如其他回复所示,您应该尝试阅读“setuptools”文档以了解更多信息。 “setup.pydevelop”是一个非常有用的功能! 尝试将它与 virtualenv 结合使用,你可以轻松地“setup.py 开发”,并且不会用你只是暂时开发的包搞乱你的系统范围的 Python:
If you download or check out the source distribution of a package — the one that has its "setup.py" inside of it — then if the package is based on the "setuptools" (which also power easy_install), you can move into that directory and say:
and it will create the right symlinks in dist-packages so that the .py files in the source distribution are the ones that get imported, rather than copies installed separately (which is what "setup.py install" would do — create separate copies that don't change immediately when you edit the source code to try a change).
As the other response indicates, you should try reading the "setuptools" documentation to learn more. "setup.py develop" is a really useful feature! Try using it in combination with a virtualenv, and you can "setup.py develop" painlessly and without messing up your system-wide Python with packages you are only developing on temporarily:
easy_install 支持下载特定版本。 例如:
将安装v1.4,如果没有指定版本,则选择最新版本1.4.1。
还支持 svn checkouts,但是使用它并不会从手动版本中给你带来太多好处。 请参阅上面的手册了解更多信息。
除非您正在开发有问题的包,否则能够切换到特定分支很少有用,而且无论如何将它们安装在站点包中通常不是一个好主意。
easy_install has support for downloading specific versions. For example:
Will install v1.4, while the latest version 1.4.1 would be picked if no version was specified.
There is also support for svn checkouts, but using that doesn't give you much benefits from your manual version. See the manual for more information above.
Being able to switch to specific branches is rarely useful unless you are developing the packages in question, and then it's typically not a good idea to install them in site-packages anyway.
easy_install 也接受源树的 URL。 至少当源位于 Subversion 中时才有效。
easy_install accepts a URL for the source tree too. Works at least when the sources are in Subversion.