简体   繁体   English

允许“ pip安装”忽略本地版本

[英]Allow “pip install” to ignore local versions

I'm using versioneer to manage versions, ala PEP 440 . 我正在使用versioneer来管理版本,例如PPE 440

I have uploaded a few versions to a private repository: 我已将一些版本上传到私有存储库:

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

My problem is that now when I use 我的问题是现在当我使用

pip install mypackage==0.0.2

I get version 0.0.2+0.0.2+18.g5a127f2.dirty when I expected to get 0.0.2 . 当我期望得到0.0.2时,我得到版本0.0.2+0.0.2+18.g5a127f2.dirty 0.0.2

Is there a way to have have pip ignore the "local version" and just install the exact version, without me having to upload to different indices (ie. staging and stable)? 有没有办法让pip忽略“本地版本”而只安装确切的版本,而无需我上传到不同的索引(即分段和稳定)?

Edit: 编辑:

I have tried using the --no-cache-dir and -I flags, but the issue persists; 我尝试使用--no-cache-dir-I标志,但是问题仍然存在; pip is preferring the 0.0.2+ version to the 0.0.2 version. pip更喜欢0.0.2+版本而不是0.0.2版本。

Additional Edit: 附加编辑:

I'm using pip 18.0 and Python 2.7 我正在使用pip 18.0和Python 2.7

According to distutils : 根据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. 因此,版本2.4比版本2.4c1更新,后者又比版本2.4b1或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). 因此,像2.4-1和2.4pl3这样的修订版比2.4更新,但比2.4.1(具有更高的发行版)要旧。

So, while not the solution I'm looking for (full answer below) it looks like this works: 因此,虽然不是我要寻找的解决方案(以下是完整答案),但它看起来像这样:

pip install "mypackage<=0.0.2"

The distutils blurb about post-releases seems to go against what is specified in PEP440 关于发行版的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. [示例:...] == 3.1:特别是3.1版(或3.1.0版),不包括所有预发行版,后发行版,开发版本和任何3.1.x维护版本。

...but I'm still a little fuzzy on how it's determined whether something is a "post" or "pre" release. ...但是对于如何确定某个东西是“发布”还是“发布”,我还是有点模糊。

Nevertheless, the answer to my problem appears to be: use Aribitrary Equality : 不过, 我的问题的答案似乎是:使用Aribitrary Equality

pip install mypackage===0.0.2

This gives me exactly the version specified, ignoring versions with any pre/post/dev details. 这给了我确切指定的版本,而忽略了具有任何pre / post / dev详细信息的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM