2

background: pip support ssh link suffix with

  1. branch name,
  2. a commit hash,
  3. a tag name
  4. a git ref

However, pip has a problem in upgrade some package depends on these ssh links.

in a setup.py of a package called CurrentPackage that is version 5.1.2

install_requires=[ "MyOwnPackage @ git+ssh://[email protected]/myusename/MyOwnPackage@master", ], 

i then pip install --upgrade -e .

Requirement already satisfied, skipping upgrade: MyOwnPackage@git+ssh://[email protected]/myusename/MyOwnPackage@master from git+ssh://****@github.com/myusename/MyOwnPackage@master in /opt/anaconda3/lib/python3.8/site-packages (from CurrentPackage==5.1.2) (0.0.1) 

The master branch is already 0.0.2. It clearly didn't upgrade MyOwnPackage to the new master branch commit, still staying at 0.0.1.

3
  • 1. first of all, you are not referring to the question. 2. Secondly, specifying the version is a common practice, tons of python setup.py require a specific version of the dependency. Commented Jan 31, 2021 at 11:15
  • Sure, but VCS (git, etc.) are special cases. You can not specify a version number, but you can specify a git tag, or a git commit instead. Commented Jan 31, 2021 at 11:17
  • @sinoroc thanks for pointing it out. I am editing my question. Commented Jan 31, 2021 at 11:20

2 Answers 2

1

pip does not check if a remote reference has been changed between installs. This means that pointing to a moving reference (like you have here) does not work as expected.

I'd suggest using:

  • specific commit hashes or tags, that are modified when you want to make upgrades
  • invoking pip with --upgrade to tell it to look around eagerly.
  • convert these packages into proper distributions and use --find-links or --index-url with that.
Sign up to request clarification or add additional context in comments.

4 Comments

--upgrade is already used. I dont want to use eager since it upgrade everything to latest version. the default only-if-needed is enough.
@LukAron Seems to me like these are OR suggestions. Use one of the 3 (or maybe combinations of the 3). But I would think that setting a specific (non-moving) git commit or git tag should be enough, no need to force with --upgrade on top of that.
@sinoroc seems that git commit or git tag doesn't work too, I later update the question
In your question you seem to use master. Typically this is a branch, more or less it is a moving reference (i.e. it does not always point at the same commit), so I would not recommend this. You really should use a non-moving reference such as a specific git commit hash or a git tag. -- Now I am not sure what you mean by "doesn't work". -- pip most likely sees that it already cloned and installed master, so why should it do it again?
-1

Ok , I conclude that it is pathetic to list the private dependency in setup.py since the syntax must be

packagename @ git+ssh://[email protected]/myusename/packagename 

simply put

-e git+ssh://[email protected]/myusename/MyOwnPackage==0.0.2 

in requirements.txt

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.