Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 259
espeed Avatar asked Mar 30 '12 19:03

espeed


People also ask

Can pip install from GitHub?

You can deploy Git locally, or use it via a hosted service, such as Github, Gitlab or Bitbucket. One of the advantages of using pip together with Git is to install the latest commits of unreleased Python packages as branches from Github.

How install pip using setup py?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.


1 Answers

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:

  • http://peak.telecommunity.com/DevCenter/setuptools#making-your-package-available-for-easyinstall
like image 148
Hugo Tavares Avatar answered Oct 24 '22 13:10

Hugo Tavares