2017-08-09 5 views
0

特定のディレクトリ(例えばexternal/など)にオンラインでリポジトリを複製するsetup.pyを書くにはどうすればいいですか?これは、Python/C++ハイブリッドプロジェクト用です。setuptoolsにクローンC++リポジトリをgitするように依頼する

私はsetup.pyを書き込もうとしました:

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

しかし、それは動作しません。

また、(Fetching remote git branch through Python setuptools)に記載されている#egg=xyzは、Pythonリポジトリではないため使用できません。

C++リポジトリはヘッダのみのライブラリです。

+0

多分、git-pythonは解決策です。 githubページにはリソースが漏れていると表示され、すべてのテストケースがウィンドウに表示されるわけではありません。また、 'git clone'を実行する前にsetup.py install gitpythonを作成する必要があります。https://stackoverflow.com/questions/15315573/how-can-i-call-git-pull-from-within-python –

+0

どの段階で'git clone' - build_extを実行しますか?リポジトリが既にクローンされている場合はどうすればよいですか? – phd

+0

C++コンポーネントがコンパイルされる前に、私はクローンをgitしたいです。 –

答えて

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}, 
    … 
) 
関連する問題