Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
Michael L Torrie
torriem at chem.byu.edu
Sun Jan 20 20:50:05 CET 2008
> Hi all,
> I am newbie in Python, my wish would be to create python applications
> for both Linux/Win32.
> I am stucked on creating a function to get the Python install
> directory (and site-packages directory) with a 100% reliable method...
> My goal is to verify if an/several extension(s) are installed and to
> automatically install the missing ones on Linux or Win32.
> I have tested sys.executable and sys.path, but I am not sure to be
> able to get what I need on different versions of Python and different
> Google was not a good friend on this, so I am very interested on how
> you implement such a function.
On both windows and Linux, installing stuff into the python install dir
requires root or administrative privileges, something most linux users
won't have unless they sudo. So if the extensions you need are missing,
and you are distributing them yourself, why not just add them into the
path at runtime, rather than messing with the user's system?
As for obtaining the installation path, the setup.py that often comes
with python modules like ldaptor, seems to be able to figure it out.
I'd check there. I think setup.py is created with distutils.
More information about the Python-list