[Distutils] Auto configuration

Bastian Kleineidam calvin@cs.uni-sb.de
Wed Dec 6 12:33:00 2000

>How can I enable running the "config" command prior to
>all "build" commands ?
Suppose your custom "config" command writes out a file "configdata". When
running the install command you can check if this file exists and if not
raise an exception which demands to run "python setup.py config":

class MyDistribution(Distribution):
    def __init__(self, attrs=None):
        Distribution.__init__(self, attrs=attrs)
        self.config_file = "configdata"

    def run_commands(self):
        if "config" not in self.commands:
            if not os.path.exists(self.config_file):
                raise SystemExit, "please run 'python setup.py config'"

class MyConfig(config):
    def run(self):
        # ... write "configdata" file