How to make setuptools clone git dependencies recursively?

2024/4/15 0:57:32

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.

Answer

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 sdistdef gitcmd_update_submodules():''' Check if the package is being deployed as a git repository. If so, recursivelyupdate 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 Truereturn Falseclass 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,},...
)
https://en.xdnf.cn/q/73175.html

Related Q&A

Stable sorting in Jinja2

It is possible to apply the sort filter in Jinja2 successively to sort a list first by one attribute, then by another? This seems like a natural thing to do, but in my testing, the preceeding sort is …

Factor to complex roots using sympy

I cant figure out how to factor an polynomial expression to its complex roots.>>> from sympy import * >>> s = symbol(s) >>> factor(s**2+1)2 s + 1

Using multiple custom classes with Pipeline sklearn (Python)

I try to do a tutorial on Pipeline for students but I block. Im not an expert but Im trying to improve. So thank you for your indulgence. In fact, I try in a pipeline to execute several steps in prepar…

Python equivalent of pointers

In python everything works by reference:>>> a = 1 >>> d = {a:a} >>> d[a] 1 >>> a = 2 >>> d[a] 1I want something like this>>> a = 1 >>> d =…

Pip is broken, gives PermissionError: [WinError 32]

I installed the python-certifi-win32 module (Im so busy trying to fix this problem that I dont even remember why I originally installed it). Right after I installed it, though, I started getting this e…

Pandas highlight rows based on index name

I have been struggling with how to style highlight pandas rows based on index names. I know how to highlight selected rows but when I have to highlight based on the index, the code is not working.Setup…

Histogram of sum instead of count using numpy and matplotlib

I have some data with two columns per row. In my case job submission time and area.I have used matplotlibs hist function to produce a graph with time binned by day on the x axis, and count per day on t…

Find subsequences of strings within strings

I want to make a function which checks a string for occurrences of other strings within them. However, the sub-strings which are being checked may be interrupted within the main string by other letters…

How to bestow string-ness on my class?

I want a string with one additional attribute, lets say whether to print it in red or green.Subclassing(str) does not work, as it is immutable. I see the value, but it can be annoying.Can multiple inhe…

How to pass Python instance to C++ via Python/C API

Im extending my library with Python (2.7) by wrapping interfaces with SWIG 2.0, and have a graph object in which I want to create a visitor. In C++, the interface looks like this:struct Visitor{virtua…