Robert,
    Thanks that was very helpful. Here is what I have come up with:

#!/usr/bin/env python
import distribute_setup
distribute_setup.use_setuptools()
from setuptools import setup
from distutils.command.build import build as _build

class build(_build):
    # Overload the built-in build command such that manpage (ec.1) is created
    # during the build phase
    def run(self):
        import manpage # simply importing the manpage creates the manpage as a 
side effect
        _build.initialize_options(self)

setup(
    name='ec',
    ...,
    data_files=[
        ('man/man1', ['ec.1'])
    ],
    setup_requires='docutils >= 0.7',
    install_requires='python >= 2.6',
    cmdclass={'build': build}
)

Initially I overloaded the run() method for build, but that only worked if 
I explicitly specified 'build' when I ran setup (i.e., 'python setup.py 
build').  
It did not work if I specified 'install', which surprised me because I thought 
install automatically ran the build command if it is needed. While it might, it 
does not execute build's run() method, even though I thoroughly cleaned the 
install directory before I ran install. So instead I overloaded 
initialize_options().  I don't know if this is a good approach, because I am 
not 
sure initialize_options() is always called.  I could also overload run() in the 
install class, but I decided against it because it seems more in keeping of the 
spirit of the build and install commands that building the manpage be done in 
the build phase.

Is this what you were thinking? Is there any way to improve on this approach?

-Ken
_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to