PEP508: why either version requirement or URL but not both?

Viewed 358

When configuring install_requires=[...] in a setup.py file, we can specify either version numbers:

package >= 1.2.3

or a source:

package @ git+https://git.example.com/some/path/to/package@master#egg=package

But I did not manager to specify both, I got an error for everything I tried.

Looking at the PEP 508, it looks like it is intended:

specification = wsp* ( url_req | name_req ) wsp*

where wsp* just means optional whitespace.

  1. Did I get it correctly that it is not possible to write something like this? package >= 1.2.3 @ git+https://...

  2. What is the reason for this decision?

1 Answers

I believe this is because getting a python package from a URL/Github does not have a way to get historical builds/packages like you would via packages stored via PyPi.

Github/URLs references a single snapshot of code, you could sort of simulate getting specific versions if you have tags or release branches in GitHub and update the URL to reference those versions:

git+https://git.example.com/some/path/to/package@master#egg=package git+https://git.example.com/some/path/to/package@develop#egg=package git+https://git.example.com/some/path/to/package@1.4.2#egg=package

Related