如何通过允许预发布来指定Python需求?

2024-10-02 02:24:25 发布

您现在位置:Python中文网/ 问答频道 /正文

对于如何正确地声明Python包的需求,我有些困惑。在

未正式发布的新版本确实具有预发布名称,如0.2.3.dev20160513165655。在

当我们添加--pre选项并且在构建开发分支时,pip安装预发行版是非常明智的。主分支不使用它。在

我发现,如果我把foobar>=0.2.3放在一个需求文件中,即使我指定了--pre参数,也不会选择开发版本。在

pip documentation在这里没有太大帮助,因为它没有指出任何关于预发布的内容。在

我使用了放置foobar>0.2.2的方法,它与{}一起安装预发行版。在

即使这有点缺陷,因为如果我们发布一个像0.2.2.1这样的修补程序,它可能已经选择了它。在

那么,最好的解决方法是什么呢?在

旁注:当我们发布一个版本(从开发到主版本的拉式请求)时,最好不要对需求文件进行修补。请记住,developbranch总是使用--pre,而master没有


Tags: pip文件方法程序版本名称声明内容
1条回答
网友
1楼 · 发布于 2024-10-02 02:24:25

如果其他人遇到这个问题,答案是in the same documentation

If a Requirement specifier includes a pre-release or development version (e.g. >=0.0.dev0) then pip will allow pre-release and development versions for that requirement. This does not include the != flag.

因此,指定>=0.2.3.dev0或类似名称应该选择“最新”的预发行版。在

请注意,如果您已经发布了0.2.3,那么它将总是比预发布(如0.2.3.dev20160513165655)排序为“更新”。PEP 440表示以下内容:

The developmental release segment consists of the string .dev, followed by a non-negative integer value. Developmental releases are ordered by their numerical component, immediately before the corresponding release (and before any pre-releases with the same release segment), and following any previous release (including any post-releases).

它还说:

... publishing developmental releases of pre-releases to general purpose public index servers is strongly discouraged, as it makes the version identifier difficult to parse for human readers. If such a release needs to be published, it is substantially clearer to instead create a new pre-release by incrementing the numeric component.

Developmental releases of post-releases are also strongly discouraged ...

所以理想情况下,您不使用日期戳,而是使用dev1dev2dev3。我认为政治公众人物实际上是说你应该使用0.2.3.dev10.2.4.dev10.2.5.dev1,但两者都是同样可读的。这实际上取决于您正在生成多少个构建。在

在您的例子中,如果0.2.3已经发布,那么所有后续的开发版本都需要是0.2.4.dev20160513165655,这样{}就会认为它是更新的。在

相关问题 更多 >

    热门问题