Search code examples
pythongitsetuptoolssetup.pydistutils

Bumped version on git private repo and now install requirements fail


I have access to a git repo that implements a dependency that I'm using in my project. Naturally, this dependency is in my requirements.txt like this:

git+https://HASH@github.com/repowner/dependency_name.git@v0.1.4

It always worked fine, but recently I needed to make some changes in the dependency, so I opened a pull request and got it reviewed by my teacher (repo owner) before merging it. In this PR I also bumped the version, and did just like a previous PR(from another author). All I changed was a changelog file that is pure text and the setup.py:

setup.py

from setuptools import setup, find_packages

setup(
    name="dependency_name",
    version='0.1.5', #<<< Only changed this from 0.1.4 to 0.1.5
    description="Desc",
    license='...',
    platforms=['OS Independent'],
    keywords='...',
    author='...',
    url="https://github.com/repoowner/dependency_name",
    packages=find_packages()
)

I assumed this was enough (as it was done like this before). I've updated my requirements.txt to:

git+https://HASH@github.com/repowner/dependency_name.git@v0.1.5  

But now, when I try to pip install -r requirements.txt I get:

Collecting git+https://****@github.com/repoowner/dependency_name.git@v0.1.5 (from -r requirements.txt (line 3))
  Cloning https://****@github.com/repoowner/dependency_name.git (to revision v0.1.5) to /tmp/pip-req-build-fvq5k_04
  Running command git clone -q 'https://****@github.com/repoowner/dependency_name.git' /tmp/pip-req-build-fvq5k_04
  WARNING: Did not find branch or tag 'v0.1.5', assuming revision or ref.
  Running command git checkout -q v0.1.5
  error: pathspec 'v0.1.5' did not match any file(s) known to git
ERROR: Command errored out with exit status 1: git checkout -q v0.1.5 Check the logs for full command output.

Did I missed something when trying to bump the version?

BTW: If I try the 0.1.4 it installs without my recent changes.


Solution

  • You forgot to tag the PR/merge commit with v0.1.5 tag, as suggested by the error message:

    WARNING: Did not find branch or tag 'v0.1.5', assuming revision or ref.
    

    You can confirm this by listing existing tags with the command git tag.

    To create and push the tag:

    • Use the command git log (you can add --pretty=oneline to get an easier-to-read output) and find the hash of your most recent commit that you would like to be included in the v0.1.5 tag/version

    • Create the new tag with the command git tag -a v0.1.5 <hash_of_your_commit>

    • Push the new tag with git push --tags

    See git docs about basic usage of tags

    See git docs for git tag subcommand