[Distutils] Using code from a dependency in setup.py
George V. Reilly
george at reilly.org
Wed May 29 21:33:41 CEST 2013
I have a little web framework, let's call it Bread, which is used to
build applications like Jam, Marmalade, PeanutButter, and other
toppings. Bread both *builds* and *serves* these applications.
I'm trying to figure out how to make the applications' `setup.py`s
work, given the following requirements:
* The apps depend upon Bread, via
* To build an application at development time, Bread reads some config
and then emits assets (HTML, JS, CSS, images, etc) to the
application's `output` directory. In other words, `bread devserver`
reads `Jam/bread.yaml` and assembles assets in `Jam/output`, then
serves the application (via Flask, but that's not otherwise pertinent).
* In order to build a *deployable* Jam application, I want to invoke
Bread during `python setup.py install` of Jam, to build
`Jam/output`. In production, Jam should not need to build anything.
* I've defined a custom `bdist_egg` setup command where
`initialize_options` imports Bread, invokes the builder, then sets
`self.distribution.data_files` with the appropriate tuples, before
calling the base class. (And *that* was no fun to figure out.)
* Right now, the `bdist_egg` is defined in Jam's `setup.py`. I want to
move this and other boilerplate code into `bread.setup`, so that I
can reuse it in Marmalade, PeanutButter, etc.
* Potentially, this means that I'm now importing Bread code before
Bread has been installed. This will surely arise in a clean install,
such as a fresh virtualenv on a build machine.
Can this be done with Distutils / setuptools / Distribute?
/George V. Reilly george at reilly.org Twitter: @georgevreilly
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Distutils-SIG