
I'm currently trying to start looking into auto-configuration... is there a way to access the parsed config.h file from within the "config" command instance ?
Also, the config class doesn't allow defining macros (e.g. to enable full __GNU__ support in gcc). Is there a way to define per-compiler define symbols in the setup() constructor or by subclassing compiler classes ?
Thanks,

How can I enable running the "config" command prior to all "build" commands ?
Thanks,

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'" Distribution.run_commands(self)
class MyConfig(config): def run(self): # ... write "configdata" file
Bastian

Bastian Kleineidam wrote:
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'" Distribution.run_commands(self)
class MyConfig(config): def run(self): # ... write "configdata" file
Thanks for the example. What I was thinking of is a little different though: I have a configuration class which will do some environment testing in order to determine flags and options for the build_ext class. Now in order to have this information available before the build I need to assure that the config command is executed before the build step.
After some hacking I found that the following trick enables this:
from distutils.command.config import config from distutils.command.build import build
class autoconf(config):
def run(self):
...config code... build_ext = self.distribution.reinitialize_command('build_ext') # Set options build_ext.define = mydefines
class autoconf_build(build):
def run(self):
self.run_command('autoconf') build.run(self)
and then in setup():
cmdclass = {'autoconf': autoconf, 'build': autoconf_build},
With this setup you can execute "setup.py bdist_rpm" and the autoconf command will get executed automatically or you can run "setup.py autoconf --autoconf-option build" to pass additional options to the autoconf command.
Unfortunately, bdist_rpm doesn't seem to inherit the command options you passed to the setup.py script -- the build is done in a separate process which is invoked by RPM rather than from the original setup.py process.
Thanks,
participants (2)
-
Bastian Kleineidam
-
M.-A. Lemburg