pythondjangogitpackagingsetuptools

How to write setup.py to include a Git repository as a dependency


I am trying to write setup.py for my package. My package needs to specify a dependency on another Git repository.

This is what I have so far:

from setuptools import setup, find_packages

setup(
    name='abc',
    packages=find_packages(),
    url='https://github.abc.com/abc/myabc',
    description='This is a description for abc',
    long_description=open('README.md').read(),
    install_requires=[
        "requests==2.7.0",
        "SomePrivateLib>=0.1.0",
        ],
    dependency_links = [
     "git+git://github.abc.com/abc/SomePrivateLib.git#egg=SomePrivateLib",
    ],
    include_package_data=True,
)

When I run:

pip install -e https://github.abc.com/abc/myabc.git#egg=analyse

I get

Could not find a version that satisfies the requirement SomePrivateLib>=0.1.0 (from analyse) (from versions: ) No matching distribution found for SomePrivateLib>=0.1.0 (from analyse)

What am I doing wrong?


Solution

  • Note: this answer is now outdated. Have a look at this answer for up-to-date instructions: https://stackoverflow.com/a/54701434/212774


    You can find the right way to do it here.

    dependency_links=['http://github.com/user/repo/tarball/master#egg=package-1.0']
    

    The key is not to give a link to a Git repository, but a link to a tarball. GitHub creates a tarball of the master branch for you if you append /tarball/master as shown above.