如何使setuptools安装不在PyPI上的软件包? [英] How can I make setuptools install a package that's not on PyPI?
问题描述
我刚刚开始使用setuptools和virtualenv。我的软件包需要最新的python-gearman,该工具仅可从GitHub获得。 PyPI上的python-gearman版本是旧版本。 Github的源代码是setuptools兼容的,即具有setup.py等。是否可以通过一种方法来使setuptools下载并安装新版本,而不是在PyPI上查找并安装旧版本?
I've just started working with setuptools and virtualenv. My package requires the latest python-gearman that is only available from GitHub. The python-gearman version that's on PyPI is an old one. The Github source is setuptools-compatible, i.e. has setup.py, etc. Is there a way to make setuptools download and install the new version instead of looking for it on PyPI and installing the old one?
仅供参考,新的python-gearman是 http://github.com/mtai/ python-gearman
FYI, the new python-gearman is http://github.com/mtai/python-gearman
推荐答案
关键是要告诉easy_install软件包可以在哪里下载。在这种特殊情况下,可以在以下网址找到它: http://github.com/mtai / python-gearman / tarball / master 。但是,该链接本身不起作用,因为easy_install无法仅通过查看URL来知道它将会得到什么。
The key is to tell easy_install where the package can be downloaded. In this particular case, it can be found at the url http://github.com/mtai/python-gearman/tarball/master. However, that link by itself won't work, because easy_install can't tell just by looking at the URL what it's going to get.
通过将其更改为 http://github.com/mtai/python-gearman/tarball /master#egg=gearman-2.0.0beta 相反,easy_install将能够识别软件包名称及其版本。
By changing it to http://github.com/mtai/python-gearman/tarball/master#egg=gearman-2.0.0beta instead, easy_install will be able to identify the package name and its version.
最后一步是添加包的dependency_links的URL,例如:
The final step is to add the URL to your package's dependency_links, e.g.:
setup(
...
dependency_links = ['http://github.com/mtai/python-gearman/tarball/master#egg=gearman-2.0.0beta']
)
现在,在安装您的软件包时,easy_install将发现有一个可从该URL下载的 gearman 2.0.0beta,并乐于在PyPI上选择它,如果在依赖项中指定 gearman> = 2.0.0beta。
Now, when YOUR package is being installed, easy_install will discover that there is a "gearman 2.0.0beta" available for download from that URL, and happily pick it over the one on PyPI, if you specify "gearman>=2.0.0beta" in your dependencies..
(通常,这种方式要做的就是在一个人的PyPI页面上包含指向可下载源的链接;在这种情况下,如果Gearman软件包的作者包含了上述链接,那么您已经设置好了。通常,人们用'myproject-dev'标记开发版本,然后人们使用'myproject> = somever,== dev'的要求,因此,如果没有更高版本的软件包,easy_install将尝试检查或下载该版本。)
(Normally, the way this sort of thing is done is to include a link on one's PyPI page to the downloadable source; in this case, if the author of the gearman package had included a link like the above, you'd be already set. Typically, people mark the development version with 'myproject-dev' and then people use a requirement of 'myproject>=somever,==dev', so that if there isn't a package of somever or higher, easy_install will try to check out or download the release.)
使用时,您需要指定-process-dependency-links
pip
。请注意,依赖项链接处理已被弃用,并将在以后的版本中删除。
You'll need to specify --process-dependency-links
when using pip
. Note that dependency links processing has been deprecated and will be removed in a future release.
这篇关于如何使setuptools安装不在PyPI上的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!