如何使用 install_requires 从 setup.py 安装 git+https://
How to install git+https:// from setup.py using install_requires
我有一个项目,我必须从 git+https:
安装
我可以这样工作:
virtualenv -p python3.5 bla
. bla/bin/activate
pip install numpy # must have numpy before the following pkg...
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
但是,我想在 install_requires
的 setup.py 文件中使用它:
from setuptools import setup
setup(install_requires='git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI', setup_requires='numpy')
然后,pip install -e .
来自包含 setup.py
的目录
由于解析错误,这不起作用:
Complete output (1 lines):
error in bla_bla setup command: 'install_requires' must be a string or list of strings containing valid project/version requireme
nt specifiers; Invalid requirement, parse error at "'+https:/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
如果我使用 pip install -r requires.txt
安装(假设我在该文件中有相同的字符串)而不是直接使用 pip install git+...
...
则不会出现错误
如何修复这个解析错误?
到目前为止我尝试过的:
- 用“/”“”/'/'''包裹字符串
- 在字符串
前添加'r'
install_requires
必须是字符串或字符串列表,其中包含名称和可选的 URL 以从以下位置获取包:
install_requires=[
'pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
]
见https://pip.readthedocs.io/en/stable/reference/pip_install/#requirement-specifiers and https://www.python.org/dev/peps/pep-0440/#direct-references
这需要 pip install
,包括 pip install .
,不适用于 python setup.py install
。
我有一个项目,我必须从 git+https:
安装我可以这样工作:
virtualenv -p python3.5 bla
. bla/bin/activate
pip install numpy # must have numpy before the following pkg...
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
但是,我想在 install_requires
的 setup.py 文件中使用它:
from setuptools import setup
setup(install_requires='git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI', setup_requires='numpy')
然后,pip install -e .
来自包含 setup.py
由于解析错误,这不起作用:
Complete output (1 lines):
error in bla_bla setup command: 'install_requires' must be a string or list of strings containing valid project/version requireme
nt specifiers; Invalid requirement, parse error at "'+https:/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
如果我使用 pip install -r requires.txt
安装(假设我在该文件中有相同的字符串)而不是直接使用 pip install git+...
...
如何修复这个解析错误?
到目前为止我尝试过的:
- 用“/”“”/'/'''包裹字符串
- 在字符串 前添加'r'
install_requires
必须是字符串或字符串列表,其中包含名称和可选的 URL 以从以下位置获取包:
install_requires=[
'pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
]
见https://pip.readthedocs.io/en/stable/reference/pip_install/#requirement-specifiers and https://www.python.org/dev/peps/pep-0440/#direct-references
这需要 pip install
,包括 pip install .
,不适用于 python setup.py install
。