gpt4 book ai didi

python - 如何在 install_requires 中指定版本范围(setuptools、distribute)

转载 作者:IT老高 更新时间:2023-10-28 21:35:31 27 4
gpt4 key购买 nike

我想制作一个依赖于特定版本范围的包,例如>= 0.5.0, < 0.7.0 . install_requires 有可能吗?选项,如果是的话应该怎么做?

最佳答案

根据the documentation ,您的语法应该可以正常工作。该文档指出:

setuptools and pkg_resources use a common syntax for specifying a project's required dependencies. This syntax consists of a project's PyPI name, optionally followed by a comma-separated list of "extras" in square brackets, optionally followed by a comma-separated list of version specifiers. A version specifier is one of the operators <, >, <=, >=, == or !=, followed by a version identifier.

文档给出了一个这样的简单示例:

docutils >= 0.3

# comment lines and \ continuations are allowed in requirement strings
BazSpam ==1.1, ==1.2, ==1.3, ==1.4, ==1.5, \
==1.6, ==1.7 # and so are line-end comments

进一步扩展,如果您希望您的软件包需要 docutils 的版本高于 0.3 版但低于 0.5 版,这样的代码可以工作:

docutils >= 0.3, <=0.5

两个附加说明。

  1. 文档还指出,冗余/重叠的依赖规范将在内部组合,因此 docutils >= 0.3, >=0.2将合并为 docutils >= 0.3 .
  2. 另外,请注意指定冲突的版本号,"is meaningless and may therefore produce bizarre results."例如,我不知道你为什么会这样,但不要使用这个:docutils >= 0.3, <=0.2因为这是不可能的。

关于python - 如何在 install_requires 中指定版本范围(setuptools、distribute),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11472810/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com