[Distutils] Generation of script during installation

M.-A. Lemburg mal at egenix.com
Thu Dec 22 12:24:28 CET 2005


Giovanni Bajo wrote:
> Hello,
> 
> I have a problem with distutils. During installation, I need to generate a
> Python module containing information about the target installation paths.
> For instance, if an user does:
> 
> setup.py install --install-headers=/foo
> 
> my module will have to contain something along the lines of:
> 
> headers= "/foo"
> 
> I managed to do this by subclassing install_lib (overriding method run) and
> generating the module there. I access the target paths with things like
> self.get_finalized_command("install_headers").install_dir. The module is
> created into the build_dir, so that install_lib.run() then copy it together
> with the other modules at the correct location.
> 
> This works like a charm *but* breaks when doing a bdist_wininst (and
> probably a bdist_rpm, I haven't checked). I'm not sure how to deal with
> that, as the final paths will be decided at installation time (depending on
> the user's system), and that's outside of the scope of my setup.py script.
> 
> Suggestions? For instance, is there a way so that the Windows installer
> generate an installation log, which my Python script can parse to extract
> the directory information?

wininst does create an installation log (called
<packagename>-wininst.log) which is placed into the
Python directory along with an uninstall .exe which
takes care of removing the package if uninstall is
selected in the Windows software administration tool.

However, I'm not sure whether you really need this,
since only the Python installation directory is
selectable during installation with wininst.

Note that it's easy to find the installation directory
of an installed package by importing it and looking
at the package.__path__ or .__file__.

For ZIP package imports, these two attributes include
the location of the ZIP file, e.g.
/home/lemburg/tmp/mxMisc.zip/mx/Misc

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 22 2005)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Distutils-SIG mailing list