Sassan Sassan - 3 months ago 31
Git Question

How to make pip update submodules of a git repository?

I'm using pip for deploying my package and I want it to pull my package's submodules recursively whenever I upgrade my package, does anybody know how can I do so?

Answer

Whenever pip updates my repo, it runs setup.py with "develop" as its argument, so I changed my setup.py like this:

from distutils.core import setup
from setuptools.command.develop import develop
from subprocess import check_call
from os import path

class update_submodules(develop):
    def run(self):
        print 1
        if path.exists('.git'):
            check_call(['git', 'submodule', 'update', '--init', '--recursive'])
        develop.run(self)

a = setup(cmdclass = {"develop": update_submodules},
      ...

it means that before running default procedure of "setup.py develop" run "git submodule update --init --recursive".