I'm using pbr which uses a requirements.txt file to look for dependencies.
I've a line in requirements.txt like git+ssh://[email protected]/user/repo.git and it works when I run pip install -r requirements.txt
However, when I run python setup.py build I run in to the error:
error in setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'+ssh://g'"
There are many Stack Overflow answers that deal with this problem exclusively when using setuptools and all of them suggest putting the Git dependency into the dependency_links list in setup.py.
I would like pbr to be able to deal with my Git dependency directly from requirements.txt in a way that works when I run both python setup.py build and pip install -r requirements.txt.
Is this possible? Are there any close workarounds?
In the example you provided, pbr is propagating the whole line to install_requires, which produces an invalid line.
Provide the requirement name via #egg=name
For it to work as intended, the url needs a
#eggsuffix to tell pbr what requirement is provided by that URL. If the URL looks like this, pbr will scrape a requirement out of the#eggpart and propagate onlyrepotoinstall_requires:Version constraints
If a version is included, pbr will add a
>=constraint on it. So this would becomerepo>=1.2.3ininstall_requires:Dependency Links
It'll also extract a dependency_link item that contains the full URL. You can use it by passing
--process-dependency-linksto pip. By default, pip will return the errorCould not find a version that satisfies the requirement repounless the package is also available via PyPI. If--process-dependency-linksis specified, then it'll fetch it from the Git URL instead.Use the -e flag, or require
pbr>=1.9.0Prior to version 1.9.0, pbr only recognized
httpandhttpsURLs, unless the line started with-e. It added support forgit://,git+ssh://,git+https://without-ein this commit.