<div dir="ltr"><div class="gmail_default"><div class="gmail_default"><font face="trebuchet ms, sans-serif">I have a little web framework, let's call it Bread, which is used to</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">build applications like Jam, Marmalade, PeanutButter, and other</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif">toppings. Bread both *builds* and *serves* these applications.</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"><br></font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif">I'm trying to figure out how to make the applications' `setup.py`s</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">work, given the following requirements:</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"><br></font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">* The apps depend upon Bread, via</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> [setuptool's install_requires](<a href="http://peak.telecommunity.com/DevCenter/setuptools#declaring-dependencies">http://peak.telecommunity.com/DevCenter/setuptools#declaring-dependencies</a>)</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif">* To build an application at development time, Bread reads some config</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> and then emits assets (HTML, JS, CSS, images, etc) to the</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> application's `output` directory. In other words, `bread devserver`</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> reads `Jam/bread.yaml` and assembles assets in `Jam/output`, then</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> serves the application (via Flask, but that's not otherwise pertinent).</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">* In order to build a *deployable* Jam application, I want to invoke</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> Bread during `python setup.py install` of Jam, to build</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> `Jam/output`. In production, Jam should not need to build anything.</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif">* I've defined a custom `bdist_egg` setup command where</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> `initialize_options` imports Bread, invokes the builder, then sets</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> `self.distribution.data_files` with the appropriate tuples, before</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> calling the base class. (And *that* was no fun to figure out.)</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif">* Right now, the `bdist_egg` is defined in Jam's `setup.py`. I want to</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> move this and other boilerplate code into `bread.setup`, so that I</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> can reuse it in Marmalade, PeanutButter, etc.</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">* Potentially, this means that I'm now importing Bread code before</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"> Bread has been installed. This will surely arise in a clean install,</font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif"> such as a fresh virtualenv on a build machine.</font></div>
<div class="gmail_default"><font face="trebuchet ms, sans-serif"><br></font></div><div class="gmail_default"><font face="trebuchet ms, sans-serif">Can this be done with Distutils / setuptools / Distribute?</font></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">
<div dir="ltr"><font face="trebuchet ms,sans-serif"><font face="trebuchet ms,sans-serif"><font face="trebuchet ms,sans-serif"><div>-- </div><div>/George V. Reilly <a href="mailto:george@reilly.org" target="_blank">george@reilly.org</a> Twitter: @georgevreilly</div>
<div><a href="http://www.georgevreilly.com/blog" target="_blank">http://www.georgevreilly.com/blog</a> <a href="http://blogs.cozi.com/tech" target="_blank">http://blogs.cozi.com/tech</a> </div></font></font></font></div>
<br></div></div></div>