[Distutils] getting installation location from distutils without changing the filesystem?

Matthias Klose doko at ubuntu.com
Fri Apr 10 18:33:57 CEST 2009

The current python.m4 macro in automake (aclocal) is a bit broken, because
'${prefix}' is passed literally to get_platform_lib(). currently trying to
replace this with something different.

Besides fixing the quoting, the implmentation seems to be questionable
(currently distutils.sysconfig.get_platform_lib() is used in this test), because
distutils.sysconfig.get_platform_lib() points to the platform library, not the
installation the module should be installed to, which is not the same in all
cases. Now trying not to use get_platform_lib(), but trying to run an setup
install command with --dry-run, and make this work with any distutils included
in 2.0 and up.

- $ python -c "from distutils.core import setup; setup()" -n install
running install
running build
running install_egg_info
Creating /usr/local/lib/python2.6/site-packages/
Writing /usr/local/lib/python2.6/site-packages/UNKNOWN-0.0.0.egg-info

and parsing the output only works for python versions providing egg-info files.

- not relying on .egg-info's:
 $ python -c "from distutils.core import setup; setup(py_modules=['conftest'])"
-n install
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.6
copying conftest.py -> build/lib.linux-i686-2.6
running install_lib
warning: install_lib: 'build/lib.linux-i686-2.6' does not exist -- no Python
modules to install
running install_egg_info
Creating /usr/local/lib/python2.6/dist-packages/
Writing /usr/local/lib/python2.6/dist-packages/UNKNOWN-0.0.0.egg-info

doesn't build and install the module. Building it before creates the `build'
directory. All the tests could be done in a temporary directory, just using the
build -b option doesn't work, because install doesn't know anything about -b.

running install_lib
copying build/lib.linux-i686-2.6/conftest.py ->
error: file '/usr/local/lib/python2.6/dist-packages/conftest.py' does not exist

finishes with an error although run with -n, needs again parsing of the output.

$ python -c "from distutils.core import setup; \
    print setup().get_command_obj('install', 0).install_purelib" -n -q install

looks short, but I'm unsure about the access to the install_purelib attribute of
the install command. Seems to work for python versions 2.3 and newer. Would be
glad if somebody still has 2.[012] and could check.

I would like to use the last option, but not yet sure about it should be
allowed, or if you have to fall back to the parsing of the second option.


More information about the Distutils-SIG mailing list