问题
I don't think this is a dupicate, because I tried all links I could find for the past 2 hours and none of the solutions worked. I want the user to be able to clone a repository, cd
into the directory, and run $ pip install .
(or at least pip install --process-dependency-links .
) to install the package, its pypi dependencies AND its (latest) private github dependencies assuming the user has read permissions for them. (also the devs should be able to run $ pip install -e .
)
my setup.py
:
setup (
...
install_requires=['
...
private-pkg
...
],
dependency_links=[
'git+ssh://git@github.com/private-org/private-pkg.git@master#egg=private-pkg'],
)
I also tried different variations for dependency_links:
https://github.com/private-org/private-pkg/tarball/master#egg=private-pkg
git+https://git@github.com/private-org/private-pkg.git@master#egg=private-pkg
I also tried adding a trailing -1.0.0
(for version) and it doesn't work but in any case, I'd like the user to be able to install the lastest version
Note that I can do:
pip install "git+https://github.com/private-org/private-pkg"
and it works fine, but I can't get pip install .
to work no matter what.
All these fail with the same error:
Could not find a version that satisfies the requirement private-pkg (from my-pkg==1.0.0) (form versions: ) No matching distribution found for private-pkg (from my-pkg==1.0.0)
Running it with pip install -vvv .
shows that pip
never looks for the git link, but running it with pip install --process-dependency-links -vvv .
tries to fetch it but fails for various reasons ("Cannot look at git URL", or "Could not fetch URL"). Note that --process-dependency-links
is marked as deprecated.
回答1:
pip expects to have a link to index page (such as PyPI) in dependency_links
. Any link to VCS is going to be skipped. This behavior was changed in commit 26facdd.
I recommend to define all external dependencies in requirements.txt
file and then run pip install -r requirements.txt
. Example of requirements.txt:
foo>=1.0
-e git+ssh://git@github.com/private-org/private-pkg.git@master#egg=private-pkg
See also How to state in requirements.txt a direct github source
There is an article about setup.py vs requirements.txt, which describes this misfeature.
来源:https://stackoverflow.com/questions/39165976/how-to-use-pip-and-setup-py-to-automatically-install-dependencies-that-may-be