[Distutils] Can I have distribute build a file for me?

Robert Park rbpark at exolucere.ca
Thu Aug 9 03:33:50 CEST 2012


On Wed, Aug 8, 2012 at 7:54 PM, Ken Kundert <admin at designers-guide.com> wrote:
> But I cannot help but believe there must be a better way.
> Is there some way add a hook to setup to get it to do the import for me after
> setup_requires has been processed?
> If not, is there some way to install docutils if needed before I call setup()?

I had a similar problem in which I needed to autogenerate the contents
of a .py file at build-time, and I accomplished it by overriding
build_py. setup then calls my build_py module which overwrites the
particular .py file without harming any other ones. You can see my
code here:

https://github.com/robru/gottengeography/blob/master/setup.py#L33

No ugly hacks necessary to call setup twice, it's a bit verbose but it works.

In your case, it should be essentially trivial to subclass `build`
(instead of build_py), and then to simply `import manpage` in your
custom build module, which setup will then call on it's own. Just
follow the pattern you see in my setup.py.

-- 
http://gottengeography.ca


More information about the Distutils-SIG mailing list