在 python setup.py 文件中的特定提交处拉取 git 回购
pulling a git repo at a particular commit in python setup.py file
我有一个 Python 项目,我正在使用来自 facebook 研究的 maskrcnn_benchmark
项目。
在我的持续集成脚本中,我创建了一个虚拟环境,我按照以下步骤安装这个项目:
- git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
- cd maskrcnn-benchmark
- git reset --hard 5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6
- python setup.py build develop
这工作正常,并根据需要在虚拟环境中安装所有内容。
现在我的项目有一个 setup.py
用于打包和部署我的应用程序。我怎样才能在这个 setup.py
文件中做同样的事情,即从特定的提交哈希中拉取并构建这个存储库?
感谢下面的回答和评论,我现在 setup.py 如下:
install_requires=[
'5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1',
'ninja',
'yacs',
'matplotlib',
'cython==0.28.5',
'pymongo==3.7.1',
'scipy==1.1.0',
'torch==1.0.0',
'torchvision==0.2.1',
'opencv_python==3.4.2.17',
'numpy==1.15.1',
'gputil==1.3.0',
'scikit_learn==0.19.2',
'scikit_image==0.14.0',
'sk_video==1.1.10'
],
dependency_links=[
'http://github.com/facebookresearch/maskrcnn-benchmark/tarball/master#egg=5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1'
],
无论我将 '5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1'
放在哪里,maskrcnn-benchmark
项目都会首先编译。如何做到最后安装依赖和这个包?
您可以使用 dependency_links
setup.py
即
dependency_links =[https://github.com/GovindParashar136/spring-boot-web-jsp/tarball/master#egg=8138cc3fd4e11bde31e9343c16c60ea539f687d9]
你的情况url
https://github.com/facebookresearch/maskrcnn-benchmark/tarball/master#egg=5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6
This answer 建议在 git url 中包含一个 package@
前缀将安装指定的 git 提交:
# in setup.py
setup(
# other fields
install_requires=[
"packagename@git+https://github.com/<user>/<repo>#<commit hash>",
],
)
所以在你的情况下:
# in setup.py
setup(
# other fields
install_requires=[
"maskrcnn_benchmark@git+https://github.com/facebookresearch/maskrcnn-benchmark.git#5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6",
],
)
我有一个 Python 项目,我正在使用来自 facebook 研究的 maskrcnn_benchmark
项目。
在我的持续集成脚本中,我创建了一个虚拟环境,我按照以下步骤安装这个项目:
- git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
- cd maskrcnn-benchmark
- git reset --hard 5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6
- python setup.py build develop
这工作正常,并根据需要在虚拟环境中安装所有内容。
现在我的项目有一个 setup.py
用于打包和部署我的应用程序。我怎样才能在这个 setup.py
文件中做同样的事情,即从特定的提交哈希中拉取并构建这个存储库?
感谢下面的回答和评论,我现在 setup.py 如下:
install_requires=[
'5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1',
'ninja',
'yacs',
'matplotlib',
'cython==0.28.5',
'pymongo==3.7.1',
'scipy==1.1.0',
'torch==1.0.0',
'torchvision==0.2.1',
'opencv_python==3.4.2.17',
'numpy==1.15.1',
'gputil==1.3.0',
'scikit_learn==0.19.2',
'scikit_image==0.14.0',
'sk_video==1.1.10'
],
dependency_links=[
'http://github.com/facebookresearch/maskrcnn-benchmark/tarball/master#egg=5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1'
],
无论我将 '5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6-0.1'
放在哪里,maskrcnn-benchmark
项目都会首先编译。如何做到最后安装依赖和这个包?
您可以使用 dependency_links
setup.py
即
dependency_links =[https://github.com/GovindParashar136/spring-boot-web-jsp/tarball/master#egg=8138cc3fd4e11bde31e9343c16c60ea539f687d9]
你的情况url
https://github.com/facebookresearch/maskrcnn-benchmark/tarball/master#egg=5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6
This answer 建议在 git url 中包含一个 package@
前缀将安装指定的 git 提交:
# in setup.py
setup(
# other fields
install_requires=[
"packagename@git+https://github.com/<user>/<repo>#<commit hash>",
],
)
所以在你的情况下:
# in setup.py
setup(
# other fields
install_requires=[
"maskrcnn_benchmark@git+https://github.com/facebookresearch/maskrcnn-benchmark.git#5ec0b91cc85163ac3b58265b3f9b39bb327d0ba6",
],
)