Search code examples
pythongithubpipsetuptoolsdistutils

How to configure setup.py to have pip install from GitHub master?


Rather than pushing a release to PyPi and GitHub, it would be easier to have PyPi use the latest GitHub master. Is there are proper way to do this?

I know you can list dependencies as GitHub repos in install_requires, but is there a way to do this for the primary package?

For example, when you use easy_install to install Flask, it reads from multiple sources, including GitHub, which is listed in the setup URL ( https://github.com/mitsuhiko/flask/blob/master/setup.py#L78):

$ sudo easy_install Flask
Searching for Flask
Reading http://pypi.python.org/simple/Flask/
Reading http://github.com/mitsuhiko/flask/

Is listing the URL in setup.py what causes easy_install to also read from GitHub?

If so, will it always install from GitHub if the GitHub version is more current than the PyPi version?

And does this work the same for pip?


Solution

  • If I recall correctly you can use download_url to point to the lastest tarball at GitHub.

    Do not send any sdist/bdist to PyPI, only register the package and change setup.py to something like:

    setup(...,
          download_url='https://github.com/USER/PROJECT/tarball/master')
    

    The reason those pages are read is because setuptools crawls lots of pages (starting from http://pypi.python.org/simple/) looking for any download url that looks like what the installation needs. You can see more details if you use the -v option in easy_install/pip.

    pip install -vvv flask
    



    References: