允许“pip install”忽略本地版本

2024-06-16 09:33:39 发布

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

我使用versioneer来管理版本,ala PEP 440。在

我已将几个版本上载到专用存储库:

  • 0.0.1
  • 0.0.2
  • 0.0.2+0.0.2+18.g5a127f2.dirty

我的问题是

pip install mypackage==0.0.2

当我期望得到0.0.2+0.0.2+18.g5a127f2.dirty时,我得到了版本0.0.2+0.0.2+18.g5a127f2.dirty。在

有没有办法让pip忽略“本地版本”而只安装正确的版本,而不需要我上传到不同的索引(即staging和stable)?在

编辑:

我尝试过使用--no-cache-dir-I标志,但问题仍然存在;pip更喜欢0.0.2+版本而不是0.0.2版本。在

附加编辑:

我使用的是pip 18.0和python2.7


Tags: installpipno版本编辑versioneerpep专用
1条回答
网友
1楼 · 发布于 2024-06-16 09:33:39

根据distutils

Following a release number, you can have either a pre-release or post-release tag. Pre-release tags make a version be considered older than the version they are appended to. So, revision 2.4 is newer than revision 2.4c1, which in turn is newer than 2.4b1 or 2.4a1. Postrelease tags make a version be considered newer than the version they are appended to. So, revisions like 2.4-1 and 2.4pl3 are newer than 2.4, but are older than 2.4.1 (which has a higher release number).

所以,虽然不是我要找的解决方案(下面是完整答案),但它看起来是可行的:

pip install "mypackage<=0.0.2"

关于发布后发布的distutils简介似乎与PEP440中指定的内容不符

[Examples: ...] == 3.1: specifically version 3.1 (or 3.1.0), excludes all pre-releases, post releases, developmental releases and any 3.1.x maintenance releases.

……但我对如何确定某个东西是“发布后”还是“发布前”还有些模糊。在

然而,我的问题的答案似乎是:使用Aribitrary Equality

^{pr2}$

这将给出指定的版本,忽略包含pre/post/dev详细信息的版本。在

相关问题 更多 >