2

I'm using versioneer to manage versions, ala PEP 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.

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

Edit:

I have tried using the --no-cache-dir and -I flags, but the issue persists; pip is preferring the 0.0.2+ version to the 0.0.2 version.

Additional Edit:

I'm using pip 18.0 and Python 2.7

Ryan de Kleer
  • 1,246
  • 14
  • 24
  • Are u using different venv for your project. Have u tried: `pip install --force-reinstall`? – Adelina Jul 30 '18 at 19:15
  • Are you looking for `pip install --no-cache-dir` ? – Marco D.G. Jul 30 '18 at 19:21
  • Thanks for pointing that out-- I've tried both options, but they yield the same results. My expectation is that when pip can find both versions, it should pick the specified version (verbatim), but maybe that's not how pip is intended to work in this scenario? – Ryan de Kleer Jul 30 '18 at 20:13
  • I can't reproduce this issue using a simple local PyPI repo set up [as described here](https://stackoverflow.com/a/51127695/2650249). `pip install pkg==X` installs the version X exactly. I suggest checking the HTTP request logs of your private repo server, maybe you'll get some info from there. – hoefling Jul 31 '18 at 19:58
  • Used `pip==18.0` with Python 3.6.4. – hoefling Jul 31 '18 at 20:00

1 Answers1

2

According to 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).

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

[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.

...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:

pip install mypackage===0.0.2

This gives me exactly the version specified, ignoring versions with any pre/post/dev details.

Ryan de Kleer
  • 1,246
  • 14
  • 24