bmargulies
bmargulies

Reputation: 100050

code generation in setup.py

I've got some XML files from which I intend to derive some python source code; they are things like lists of language codes. Does the distribute module have a hook I can plug into for this purpose? To be perhaps clearer, I don't want to ship XML around. I want to only ship .py files. I want to derive some .py files by running a program that generates them from XML.

Upvotes: 7

Views: 1507

Answers (1)

Matthew Trevor
Matthew Trevor

Reputation: 14962

You could create a custom distutils command for your code gen process, or you can override build itself. This would require you to include the XML, though.

I'd probably move the code generation into my local build process, using zc.buildout with a templating recipe like z3c.recipe.template. The XML would then be part of the development build, with only the code generated Python files included in the user distribution.

Upvotes: 2

Related Questions