[vtk-developers] python install prefix in setup.py

David Gobbi dgobbi at atamai.com
Thu Feb 16 09:22:36 EST 2006


Prabhu Ramachandran wrote:

>>>>>>"David" == David Gobbi <dgobbi at atamai.com> writes:
>>>>>>            
>>>>>>
>
>    David> I've looked in the distutils module and there is a method
>    David> there that we can use:
>    David> "distutils.sysconfig.get_python_lib(0,0,prefix)" will
>    David> return the path where the .py files go, and
>    David> "distutils.sysconfig.get_python_lib(1,0,prefix)" will
>    David> return the path where .so/.dll files go.  Usually these are
>    David> the same path, but some people configure their python to
>    David> keep platform-specific files (the .so files) in
>    David> platform-specific directories.
>
>FWIW this is the documentation on the method:
>
>Definition: get_python_lib(plat_specific=0, standard_lib=0, prefix=None)
>Docstring:
>    Return the directory containing the Python library (standard or
>    site additions).
>    
>    If 'plat_specific' is true, return the directory containing
>    platform-specific modules, i.e. any module from a non-pure-Python
>    module distribution; otherwise, return the platform-shared library
>    directory.  If 'standard_lib' is true, return the directory
>    containing standard Python library modules; otherwise, return the
>    directory for site-specific modules.
>    
>    If 'prefix' is supplied, use it instead of sys.prefix or
>    sys.exec_prefix -- i.e., ignore 'plat_specific'.
>
>    David> The "prefix" is tricky because, right now, it has to be
>    David> extracted from VTK_PYTHON_SETUP_ARGS.  It seems that maybe
>    David> having a VTK_PYTHON_INSTALL_PREFIX variable might be a good
>    David> idea, I'm not sure how many people use
>    David> VTK_PYTHON_SETUP_ARGS for things other than setting the
>    David> prefix. Prabhu, do you have any insight?
>
>Well, if the user uses setup.py --home=~/python or something then this
>will not work.  So all this assumes that the user is only using
>--prefix.  So if that is the only supported way then this is all fine.
>If not it is not going to be easy.  
>
>    David> To be complete, the following CMake variables should be
>    David> created (and should definitely be advanced):
>    David> VTK_PYTHON_MODULE_INSTALL_DIR for the .py/.pyc files
>    David> VTK_PYTHON_MODULE_PLAT_INSTALL_DIR for the .so/.dll files
>[...]
>
>    David> Does this sound too involved?
>
>It does sound like we are doing all that distutils automatically does
>and is quite involved.  I'm not exactly sure what we are trying to do
>here?  If what you want is total control over exactly what and where
>things go then I guess there is no other way...
>
>Sorry to be vague but I'm totally swamped with work.
>  
>

The main reason for duplicating what setup.py does to calculate the 
paths is so that
CMake can create testing scripts and setvars.sh-type scripts with the 
correct
PYTHONPATH.  It isn't so much anymore to provide control over exactly
where things are installed (we already had that discussion and you convinced
me that distutils is the way to go :).

Your input has been very valuable, I understand the way that different 
people and
different distibutions handle python installs better now.

 - David




More information about the vtk-developers mailing list