Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

setuptools - Can a Python package depend on a specific version control revision of another Python package?

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' ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to do two things. First, require the exact version you want, e.g.:

install_requires = "useful.package==1.9dev-r1234"

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"]

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.

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.

(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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...