13

I'm trying to make a project depend on a git dependency. However, I can't seem to get it to work. What I basically want to achieve is the following, but it doesn't work:

#!/usr/bin/env python3
from setuptools import setup


setup(
    name='spam',
    version='0.0.0',
    install_requires=[
        'git+https://github.com/remcohaszing/pywakeonlan.git'
    ])

I tried several variations on the above, such as adding @master or #egg=wakeonlan-0.2.2, but this doesn't make a difference.

The following works, but only when using the deprecated pip flag, --process-dependency-links:

#!/usr/bin/env python3
from setuptools import setup


setup(
    name='spam',
    version='0.0.0',
    install_requires=[
        'wakeonlan'
    ],
    dependency_links=[
        'git+https://github.com/remcohaszing/pywakeonlan.git#egg=wakeonlan-0.2.2'
    ])

This outputs:

$ pip install --no-index -e . --process-dependency-links
Obtaining file:///home/remco/Downloads/spam
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting wakeonlan (from spam==0.0.0)
  Cloning https://github.com/remcohaszing/pywakeonlan.git to /tmp/pip-build-mkhpjcjf/wakeonlan
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Installing collected packages: wakeonlan, spam
  Running setup.py install for wakeonlan ... done
  Running setup.py develop for spam
Successfully installed spam wakeonlan-0.2.2

The following does work:

pip install 'git+https://github.com/remcohaszing/pywakeonlan.git'

Also adding the git url in a requirements file just works.

Is there any non deprecated way to depend on a git url using a setup.py file?

3
  • 1
    No, that answers suggests using the deprecated dependency_links. Commented Jul 12, 2016 at 8:40
  • 1
    a related github issue: github.com/pypa/pip/issues/2023 - however I did not see a solution there yet. Commented Jul 12, 2016 at 8:52
  • 2
    At the moment, it would seem there isn't a non-deprecated way to do this :\ Commented Jul 12, 2016 at 9:24

1 Answer 1

6

Pip >= 9.1 (commit 6ec559) will have support for the new @ syntax as described in PEP508, which takes the format: pkgname@url#sum - e.g.:

pip install --no-index packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4

This will also be useable in setup.py in the same way, e.g.:

install_requires=['packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4']

You can try this out just now with the latest commit to pip master (updating pip the 'wrong' way!):

$ pip install https://github.com/pypa/pip/archive/master.zip
$ pip install --no-index packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4
Collecting packaging@ https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4 
from https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4
Downloading https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl
Installing collected packages: packaging
Successfully installed packaging-15.3
Sign up to request clarification or add additional context in comments.

1 Comment

It seems that having such a dependency prevents uploading to PyPi. Is there a plan to allow this maybe?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.