Did*_*ier 1 setuptools python-3.x
我正在尝试使用 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)
Run Code Online (Sandbox Code Playgroud)
在 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"
]
Run Code Online (Sandbox Code Playgroud)
此处建议此示例作为类似问题的解决方案。我遇到了同样的unknown url type错误(该包最终是通过 PyPI 检索的,而不是通过 VCS URL 检索的!)。
git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI#egg=pycocotools-2.0
Run Code Online (Sandbox Code Playgroud)
python3 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.0
Run Code Online (Sandbox Code Playgroud)
python3 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=pycocotools
Run Code Online (Sandbox Code Playgroud)
python3 setup.py install:unknown url type: git+https -- Some packages may not be found!pip3 install: 好的我也尝试删除git+所有这些 URL 的 ,但它cannot detect archive format.
dependency_links被宣布过时并最终在19.0中删除。pip它的替换是install_requires使用特殊语法(从 19.1 开始支持pip):
install_requires=[
'package_name @ git+https://gitlab.com/<PRIVATE_ORG>/<PRIVATE_REPO>.git@<COMMIT_ID>'
]
Run Code Online (Sandbox Code Playgroud)
请参阅https://pip.readthedocs.io/en/stable/reference/pip_install/#requirement-specifiers和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)
Run Code Online (Sandbox Code Playgroud)
例如:
install_requires=[
pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI
]
Run Code Online (Sandbox Code Playgroud)