'How to make setuptools clone git dependencies recursively?
I want to let setuptools
install Phoenix
in my project and thus added
setup(
...
dependency_links = [
"git+https://github.com/wxWidgets/Phoenix.git#egg=Phoenix"
],
install_requires = ["Phoenix"],
...
)
to my setup.py
, but Phoenix
' setuptools
setup depends on a recursive git
clone. How to tell the setuptools
setup of my project to do git clone --recursive
for Phoenix
?
Defining a git
alias with git config --global alias.clone 'clone --recursive'
doesn't change anything.
I'm using setuptools
18.2 with python
2.7 on Ubuntu 15.04.
Solution 1:[1]
I finally found an answer that could solve this! This blog post explains it. It assumes though that you have access to the source code Phoenix
in this case. Essentially, you have to apply the following addition to Phoenix
's setup.py
. It doesn't help applying it to your setup.py
sadly. In short:
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.sdist import sdist
def gitcmd_update_submodules():
''' Check if the package is being deployed as a git repository. If so, recursively
update all dependencies.
@returns True if the package is a git repository and the modules were updated.
False otherwise.
'''
if os.path.exists(os.path.join(HERE, '.git')):
check_call(['git', 'submodule', 'update', '--init', '--recursive'])
return True
return False
class GitCmdDevelop(develop):
def run(self):
gitcmd_update_submodules()
develop.run(self)
class GitCmdInstall(install):
def run(self):
gitcmd_update_submodules()
install.run(self)
class GitCmdSDist(sdist):
def run(self):
gitcmd_update_submodules()
sdist.run(self)
setup(
cmdclass={
'develop': GitCmdDevelop,
'install': GitCmdInstall,
'sdist': GitCmdSDist,
},
...
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | patzm |