Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt

pythonewbie eproust at gmail.com
Mon Jan 21 06:14:58 EST 2008


On 21 jan, 11:49, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> > Diez,
>
> > I repeat I am a newbie, so please don't be angry against me, if I say
> > something stupid or if I propose a method not efficient.
>
> Where did I sound angry?
>
> > An easy way to get the absolute path of site-packages seems very
> > useful to me, in order to check anything (all extensions available and
> > not provided by sys.path, etc.) related to the files on the
> > filesystem, if necessary.
>
> As I said - this is a wrong assumption. The whole purpose of the sys.path is
> to specify locations where modules/packages are installed. Note the plural.
>
> And matter of factly (as I told you in the last post already), this happens
> in e.g. debian based distributions install certain packages
> under /usr/share, which is by no means a prefix of /usr/python2.5 where the
> site-packages are.
>
> So if you want to find out if something is already installed, you need to
> consider ALL the contents of sys.path.
>
> Besides, I don't understand why you want to do it that way anyway. If you
> need a certain package,  do
>
> try:
>   import package
> except ImportError:
>   do_install_package()
>
> This should/could be part of your installer script (most probably setup.py)
>
> And have you heard of setuptools? They do actually manage and install
> pytthon packages with dependencies. Before reinventing another wheel...
>
> > For the automatic installation of missing extensions (using admin
> > rights), I think that it is not difficult to do it on both
> > platforms...
>
> You are underestimating that task. It is, on both platforms. There are many
> discussions about this, why some people don't like setuptools because it
> works with python as center of it's perspective whereas linux often has
> package management for the whole system.
>
> I suggest you start acquainting yourself with setuptools and how and what
> they did to essentially solve what you seem to be wanting. And try and see
> if that's not a route you can go - just using setuptools.
>
> Diez

OK 5/5, I will follow your advices !

I will read the manuals distutils and setuptools...

I use Ubuntu 7.10 and I have seen a package named python-setuptools
0.6c6-1 ready to install. The description of this package is Python
Distutils Enhancements
Extensions to the python-distutils for large or complex distributions.




More information about the Python-list mailing list