要求 setuptools git 克隆 c++ 存储库

Ask setuptools to git clone c++ repository

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

我试着写一个 setup.py 有:

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

但这不起作用。

我也不能使用 () 中描述的 #egg=xyz,因为它不是 python 存储库。

C++ 存储库是一个 header-only 库。

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},
    …
)