[Distutils] obtaining easy_install prefix in setup.py

Pavol Juhas pj2192 at columbia.edu
Wed Nov 18 20:59:21 CET 2009


Hello,

I searched and read the recent discussions on the distutils-sig
list and I hope someone can help me with the following problem.

Is there a way to recover the prefix value inside pkgfoo/setup.py,
when it is installed as

    easy_install --prefix=value pkgfoo
    (pkgfoo is a directory with setup.py)

I can get the prefix, when pkgfoo is installed with

    python setup.py install --prefix=value

by overloading the bdist_egg class and passing it via
cmdclass argument to the setup function:

http://danse.us/trac/diffraction/browser/diffraction/diffpy.lib/trunk/setup.py
http://danse.us/trac/diffraction/browser/diffraction/diffpy.lib/trunk/setup_scons.py

However, this does not work under easy_install, because
easy_install already creates its own distribution object
before sourcing pkgfoo/setup.py, in addition setup.py
is executed in a sandbox with mangled sys.argv.

Has anybody, perhaps David Cournapeau, figured out how to wrestle
the prefix value out of easy_install?

Thank you all,

Pavol

PS: Let me give you some background for what I am trying to do.

    I am working on several Python packages that need to be distributed
    together with a shared C++ library (libdiffpy.so).  So far I
    have used scons to build and install the library and that has
    been working really well.  However, I would like to have a
    dependency resolution for any client packages as available in the
    setuptools.  After wading through the "People want CPAN" thread
    I realized that converting my scons scripts to distutils would be
    a hopeless task.  So my solution is to package the library sources
    in a phony python package diffpy.lib, where its setup.py is extended
    to execute scons that actually takes care of the library build
    and installation.  I have decided to ignore all setup.py options
    and take care of the prefix under which the library should be
    installed.  However to do so, I need to recover the prefix value
    and pass it to scons.


More information about the Distutils-SIG mailing list