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.
For it to work as intended, the url needs a #egg
suffix to tell pbr what requirement is provided by that URL. If the URL looks like this, pbr will scrape a requirement out of the #egg
part and propagate only repo
to install_requires
:
git+ssh://[email protected]/user/repo.git#egg=repo
If a version is included, pbr will add a >=
constraint on it. So this would become repo>=1.2.3
in install_requires
:
git+ssh://[email protected]/user/repo.git#egg=repo-1.2.3
It'll also extract a dependency_link item that contains the full URL. You can use it by passing --process-dependency-links
to pip. By default, pip will return the error Could not find a version that satisfies the requirement repo
unless the package is also available via PyPI. If --process-dependency-links
is specified, then it'll fetch it from the Git URL instead.
pbr>=1.9.0
Prior to version 1.9.0, pbr only recognized http
and https
URLs, unless the line started with -e
. It added support for git://
, git+ssh://
, git+https://
without -e
in this commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With