Search code examples
gitpippypi

What is the relationship between Git and PyPI?


I am trying to set up and PyPI package, and getting a little bit confused.

I understood that you have to use Git with PyPI, so I moved my code there. I think that you have to have a link to you git repository in the URL parameter of setup.py, or PyPI won't accept it.

Now, I have been uploading my project to TestPyPI using

python setup.py sdist upload -r pypitest

and things seem to work.

Now, I am wondering about what to do with download_url.

My thoughts about what I think/wish should happen:

I set

download_url=https://github.com/gituser/myproject/releases/latest/

or something similar. Then, when I make a new release on Git, PyPI will somehow find it and automatically update my package (including updating the version number and description on the project PyPI page).

This doesn't seem to be happening. I'm not sure if it is because I am doing the download_url wrong, or the version numbering wrong, or if my expectation about what is supposed to happen is wrong.

If it is the latter and I have to upload each new release to PyPI myself, what is the point of having it linked up with Git?


Solution

  • PyPI and GitHub are unrelated from an operational perspective.

    PyPI will happily accept packages that do not link to a git repository with the url field. There are indeed many packages whose setup.py's url field is to the PyPI page, see the page of sympy.

    The documentation of setuptools includes also a download_url field. Apparently, if this links refers to a page that contains so-called primary links to releases of your software, these releases appear on PyPI. I have never used this myself and I had trouble finding examples online.

    The following package is apparently setup to work this way but it is hard to tell if the link on PyPI is there because the author manual put it or if it was automatically updated.

    I'll just conclude with the remark that, in general, package authors prefer to perform the update manually to control what is released on PyPI and that the preferred method for uploading packages is to use twine, see the "Package Authors" box on https://pypi.python.org/pypi