Python setuptools: How can I list a private repository under install_requires?
Question: I am creating a `setup.py` file for a project which depends on private GitHub
repositories. The relevant parts of the file look like this:

    
    
    from setuptools import setup
    setup(name='my_project',
        ...,
        install_requires=[
            'public_package',
            'other_public_package',
            'private_repo_1',
            'private_repo_2',
        ],
        dependency_links=[
            'https://github.com/my_account/private_repo_1/master/tarball/',
            'https://github.com/my_account/private_repo_2/master/tarball/',
        ],
        ...,
    )
    

I am using `setuptools` instead of `distutils` because the latter does not
support the `install_requires` and `dependency_links` arguments per
[this](http://stackoverflow.com/questions/9810603/adding-install-requires-to-
setup-py-when-making-a-python-package) answer.

The above setup file fails to access the private repos with a 404 error -
which is to be expected since GitHub returns a 404 to unauthorized requests
for a private repository. However, I can't figure out how to make `setuptools`
authenticate.

Here are some things I've tried:

  1. Use `git+ssh://` instead of `https://` in `dependency_links` as I would if installing the repo with `pip`. This fails because setuptools doesn't recognize this protocol ("unknown url type: git+ssh"), though the [distribute documentation](http://pythonhosted.org/distribute/setuptools.html#dependencies-that-aren-t-in-pypi) says it should. Ditto `git+https` and `git+http`.

  2. `https://<username>:<password>@github.com/...` \- still get a 404. (This method doesn't work with `curl` or `wget` from the command line either - though `curl -u <username> <repo_url> -O <output_file_name>` does work.)

  3. Upgrading setuptools (0.9.7) and virtualenv (1.10) to the latest versions. Also tried installing distribute though [this overview](http://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2) says it was merged back into setuptools. Either way, no dice.

Currently I just have `setup.py` print out a warning that the private repos
must be downloaded separately. This is obviously less than ideal. I feel like
there's something obvious that I'm missing, but can't think what it might be.
:)

Duplicate-ish question with no answers
[here](http://stackoverflow.com/questions/12956168/python-how-to-connect-to-a-
protected-svn-repository-with-setuptools).


Answer: Here's what worked for me:

    
    
      install_requires=[
          'private_package_name==1.1',
      ],
      dependency_links=[
          'git+ssh://git@github.com/username/private_repo.git#egg=private_package_name-1.1',
      ]
    

Note that you have to have the version number in the egg name, otherwise it
will say it can't find the package.

