我正在尝试使用setuptools从VCS和子目录中安装一个依赖项。
我的setup.py看起来是这样的:
#!/usr/bin/env python3
from setuptools import setup
required = [
"package"
]
dependency_links = [
"git+ssh://git@host/repo.git@tag#subdirectory=subdir#egg=package-version"
]
setup(install_requires=required, dependency_links=dependency_links)在virtualenv中运行python3 setup.py install,将得到以下错误:
Download error on git+ssh://git@host/repo.git@tag#subdirectory=subdir#egg=package-version: unknown url type: git+ssh -- Some packages may not be found!
为了调试起见,我使用了以下公共Github:
required = [
"pycocotools"
]
dependency_links = [
"git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI#egg=pycocotools-2.0"
]该示例建议使用这里作为类似问题的解决方案。我得到了相同的unknown url type错误(包最终是通过PyPI检索的,而不是通过VCS !)。
我试过的
git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI#egg=pycocotools-2.0python3 setup.py install:unknown url type: git+https -- Some packages may not be found!pip3 install:ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/pip-install-lwpbj7yv/pycocotools-2.0/PythonAPI#egg=pycocotools-2.0': '/tmp/pip-install-lwpbj7yv/pycocotools-2.0/PythonAPI#egg=pycocotools-2.0'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI&egg=pycocotools-2.0python3 setup.py install:unknown url type: git+https -- Some packages may not be found!pip3 install:好的,但是WARNING: Generating metadata for package pycocotools-2.0 produced metadata for project name pycocotools. Fix your #egg=pycocotools-2.0 fragments.git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI&egg=pycocotoolspython3 setup.py install:unknown url type: git+https -- Some packages may not be found!pip3 install:OK我也尝试为所有这些URL删除git+,但它是cannot detect archive format。
我正在使用的版本
发布于 2020-05-21 09:35:57
dependency_links被宣布为过时,最后在pip 19.0中被宣布为删除。它的替代品是具有特殊语法的install_requires (自pip 19.1以来支持):
install_requires=[
'package_name @ git+https://gitlab.com/<PRIVATE_ORG>/<PRIVATE_REPO>.git@<COMMIT_ID>'
]见安装/#要求-说明符和https://www.python.org/dev/peps/pep-0440/#direct-references
这需要pip install,包括pip install .,而不适用于python setup.py install。
就你而言:
install_requires=[
"package @ git+ssh://git@host/repo.git@tag#subdirectory=subdir"
]
setup(install_requires=install_requires)例如:
install_requires=[
pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI
]https://stackoverflow.com/questions/61930615
复制相似问题