How can I add dependency link to repo subdirectory in setup.py

半腔热情 提交于 2020-06-25 09:03:08

问题


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>



来源:https://stackoverflow.com/questions/50249571/how-can-i-add-dependency-link-to-repo-subdirectory-in-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!