【问题标题】:Ask setuptools to git clone c++ repository询问 setuptools 到 git clone c++ 存储库
【发布时间】:2018-01-17 20:31:12
【问题描述】:

如何编写一个setup.py,它将在线git克隆一个存储库到特定目录(如external/)?这是一个 python/c++ 混合项目。

我尝试用以下方式写setup.py

setup(
    name='test',
    ...    
    dependency_links=['https://blah/master.zip'],
)

但这不起作用。

我也不能使用 (Fetching remote git branch through Python setuptools) 中描述的#egg=xyz,因为它不是 python 存储库。

c++ 存储库是一个只有头文件的库。

【问题讨论】:

  • 也许 git-python 是一个解决方案。 github页面说它泄漏资源并且并非所有测试用例都通过窗口。在执行git clonestackoverflow.com/questions/15315573/…之前还需要使 setup.py install gitpython
  • 您想在哪个阶段运行git clone — build_ext?如果仓库已经被克隆了怎么办?
  • 我想在编译 c++ 组件之前进行 git clone。

标签: python git setuptools


【解决方案1】:
from setuptools.command.build_ext import build_ext
import subprocess

class git_clone_external(build_ext):
    def run(self):
        subprocess.check_call(['git', 'clone', 'https://git.example.com'])
        build_ext.run(self)

setup(…
    cmdclass = {'build_ext': git_clone_external},
    …
)

【讨论】:

    猜你喜欢
    • 2022-09-27
    • 2021-09-01
    • 2015-07-30
    • 2019-09-16
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    相关资源
    最近更新 更多