How can I add dependency link to repo subdirectory

2020-08-22 03:07发布

问题:

I have following two repositories: one classic with setup.py, and second which looks like:

/repo /folder1 /folder2 /utils /setup.py

and in setup.py in first repo I want install utils from second repo. I tried following code:

install_requires=["repo"],
dependency_links=['git+ssh://git@bitbucket.aaaaaaa.aa:0000/project/repo@master#egg=repo&subdirectory=folder2']

but after python setup.py develop I have following error:

unknown url type: git+ssh -- Some packages may not be found!

回答1:

I had the same issue.

janfreyberg answer does not work anymore because of a change in pip: since 19.0, dependency_links are now obsolete.

Since pip 18.1, we can put these dependencies in install_requires using a syntax introduced by PEP 508.

Here is the solution in your case:

install_requires=[
    'repo @ git+ssh://git@bitbucket.aaaaaaa.aa:0000/project/repo@master#subdirectory=folder2'
]

setup(install_requires=install_requires)

Note that this requires using pip install . and doesn't work with python setup.py install.

If folder2 itself has dependencies, everything will be retrieved recursively.



回答2:

I found this works for me:

depndendcy_links=["git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI#egg=pycocotools-2.0"]

So, specify the subdirectory and version as #subdirectory=<sub_dir>#<packagename>-<version>