[Distutils] Variable substitution

Stefan Seefeld seefeld at sympatico.ca
Fri Oct 3 08:57:20 EDT 2003


Joel Becker wrote:
> Folks,
> 	A quick look at the distutils source, some extensive googling,
> and even walking a few months of the distutils-sig archive all have yet
> to yield an answer to my quandry.  I'm looking to substitute some
> variables at 'build' time ala what autoconf/configure does to .in files.
> I have some configuration I want to set up with my setup.py script and
> insert into a file (specifically, the location of some support files).
> 	I can't find a way to do this in distutils.  My first thought
> was to do the work by hand before calling distutils.core.setup(), but
> then I realized that I'd have no idea what setup() thought certain
> values would be (eg, prefix) until after I'd called it.
> 	Is there a recommended way to accomplish this?  Is there a way I
> can add this?  A quick pointer would help.

hey Joel,

I had the exact same question some months ago. Indeed, there doesn't
seem to be a way to do this with existing distutils features.
What I did was to provide my own installation command that does
the value replacement on the fly when copying files to their final
destination.
Just for the record: even that might not be enough if, as is the case
with the windows installer generated by 'bdist_wininst', the prefix
is only known when you invoke the installer, not when you call
python setup.py install.

I'd really like distutils to provide better support for this kind
of thing. It doesn't seem that uncommon to have 'datafiles' that
have to be referenced from inside the code.

Hope that gets you started,

		Stefan





More information about the Distutils-SIG mailing list