On Thu, 12 Mar 2009, Christian Heimes wrote:

I've attached a patch that hooks into the build process. With the patch
the config file is created right before the .py files are copied into
the build directory.

Thanks for the patch. A few comments:

    def run(self):

        if (not os.path.exists(self.jcc_config_file) or
            not "install" in self.distribution.commands):
            self.create_jcc_config()

It looks to me as If one edits setup.py or changes one of the JCC_ env vars and then runs 'python setup.py build install' again, with config.py existing, the changes made are not taken into account, config.py is not getting regenerated.

The logic here is tricky to get right and the failure silent (as before). Basically, what we want is config.py to _not_ be regenerated during install, only during 'build'.

The problem is that, regardless of whether it needs to be, your build_py's run() is also always called when just 'install' is requested. I've verified this with pdb and by inspecting self.distribution.commands inside run().

The check for existence then has the problem mentioned above and the check for 'install' not being in self.distribution.commands, made to force re-creation when just 'build' is requested breaks down when both 'build' and 'install' are requested together.

I'm afraid that, at this point, this patch is not improving much on the situation that got this started, the minor inconvenience (I quote) of having to tell sudo to inherit the environment so that config.py doesn't get smashed with defaults during install.

In other words, you're fixing this with this patch by introducing another such inconvenience, both with a silent failure. It doesn't look like the trade off is worthwhile.

This is not saying anything about the quality or cleverness of the patch itself. It taught me something about how do customize build.

Since you've already put in place the build_py customization, it would be a shame to lose this. Is there a better way to implement run() so that the logic for deciding on generating config.py doesn't have the flaws above ? Is there a way to have config.py created only during a real 'build' ?

The MANIFEST.in file must be placed next to setup.py. It prevents
jcc/config.py from getting placed in a source release.

Thanks, I added that one.

Andi..

Reply via email to