问题描述
一些有用的Python软件包在pypi上被破坏,并且唯一可接受的版本是版本控制系统中的特定版本.可以用setup.py
例如
Some useful Python packages are broken on pypi, and the only acceptable version is a particular revision in a revision control system. Can that be expressed in setup.py
e.g
requires = 'svn://example.org/useful.package/trunk@1234'
吗?
推荐答案
您需要做两件事.首先,要求您想要的确切版本,例如:
You need to do two things. First, require the exact version you want, e.g.:
install_requires = "useful.package==1.9dev-r1234"
,然后包含一个dependency_links
设置,指定在哪里找到它:
and then include a dependency_links
setting specifying where to find it:
dependency_links = ["svn://example.org/useful.package/trunk@1234#egg=useful.package-1.9dev-r1234"]
请注意,dependency_links
URL的版本#egg=
部分必须完全与您在install_requires
中指定的内容完全匹配;这就是将这两部分链接在一起的原因.
Note that the version #egg=
part of the dependency_links
URL must exactly match what you specified in install_requires
; this is what links the two pieces together.
发生的情况是,setuptools在链接上看到#egg标记,并将该URL保存为该精确版本的软件包的可用下载URL.然后,当稍后尝试解决该要求时,应下载该精确的SVN URL.
What happens is that setuptools sees the #egg tag on the link and saves the URL as an available download URL for that precise version of the package. Then, when it tries to resolve that requirement later, it should download that precise SVN URL.
(不过,请注意,要真正实现此功能,目标SVN修订版实际上必须使用该名称和版本来构建一个鸡蛋.否则,您的依赖项将在运行时失败!因此,这仅在您所依赖的软件包的默认内部版本号中使用SVN修订标签时才有效.)
(Note, however, that for this to really work, the targeted SVN revision has to actually build an egg with that name and version. Otherwise, your dependency will fail at runtime! So, this really only works if the package you're depending on uses SVN revision tags in their default build version numbers.)
这篇关于Python软件包可以依赖于另一个Python软件包的特定版本控制修订版吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!