Search code examples
pythongitsetuptoolssetup.pydistutils

Latest git tag not recognized when installing requirements.txt


I have a dependency in my requirements.txt that comes from another git repo (not mine, but I have access to it).

Yesterday I merged a PR and after applied the tag v0.1.5 to it. In sequence I updated my projects requirements to:

git+https://[email protected]/repowner/[email protected]  

The dependency installed with no issues. However I spotted a bug and decided to fix it. I created a new branch, changed the version in the setup.py, assigned the tag v0.1.5b, and used git push and git push --tags, all before merging. (I assumed this was the right way to do it, instead of applying it later)

Now I updated my requirements to

git+https://[email protected]/repowner/[email protected]

However the version v.0.1.5 is the one getting installed when I execute pip install -r requirements.txt. It doesn't raise any error, it simple ignores the b in the end. I tried to assign the tag into master by using git tag -a v0.1.5b <commit_hash> but I get the return:

fatal: tag 'v0.1.5b' already exists

If I try to just push the tags:

Everything up-to-date

I'm not sure if I wasn't supposed to use the 'b' in the version or there is something else I might have missed? Can someone help me fix it? It would be nice if I can solve it without pushing another commit, (like a v.0.1.6) but I take any solution tbh.


Solution

  • Valid Python public version identifiers all end in a digit:

    Public version identifiers

    The canonical public version identifiers MUST comply with the following scheme:

    [N!]N(.N)*[{a|b|rc}N][.postN][.devN]`
    

    Choosing a versioning scheme is much easier to read than the above PEP 440 description. Here also you'll notice that all patterns end in a digit.

    Given that you don't want to increment to v0.1.6, you have the following alternate options:

    • v0.1.5.post1
    • v0.1.5.dev1

    Side note: To reassign a tag that you already created to a different commit, use the -f flag on your git tag command and then try that push again.