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

P

pythonewbie

pythonewbie




Depending on your goal. You said

"""
My goal is to verify if an/several extension(s) are installed and to
automatically install the missing ones on Linux or Win32.
"""

This goal can't be reached with only the site-packages - because I can
install packages somewhere else (matter of factly, this happens on debian
for example, they've split the install-dirs and created a bunch of dirs
under /usr/share)

So having a method that gives you the installation root doesn't help much
here.

Diez

To John Machin,
['', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/
python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/
python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/
usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/
Numeric', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/
python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0',
'/var/lib/python-support/python2.5/gtk-2.0', '/usr/lib/python2.5/site-
packages/wx-2.8-gtk2-unicode']
 
P

pythonewbie

pythonewbie




Depending on your goal. You said

"""
My goal is to verify if an/several extension(s) are installed and to
automatically install the missing ones on Linux or Win32.
"""

This goal can't be reached with only the site-packages - because I can
install packages somewhere else (matter of factly, this happens on debian
for example, they've split the install-dirs and created a bunch of dirs
under /usr/share)

So having a method that gives you the installation root doesn't help much
here.

Diez

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.

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.

For the automatic installation of missing extensions (using admin
rights), I think that it is not difficult to do it on both
platforms...
 
J

John Machin

To John Machin,

Get a clue #1: read the instructions for your news client ... like the
bit that says "click on the message/posting that you want to reply to"
['', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/
python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/
python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/
usr/lib/python2.5/site-packages',

Get a clue #2: it "doesn't work" because it needs a different pattern
on *x platforms.

Consider proceeding in this order:
1. get some clues
2. write an app, test it, etc
3. do the setup.py thingie for Windows & Linux
4. persuade some people to install it and test it
5. then and only then look into "verify if an/several extension(s) are
installed and to automatically install the missing ones"

By the way, I understand "extensions" to mean modules/packages written
substantially or wholly in C or C++. Is that what you mean? If so, do
1-5 above with a Python-only module first.

BTW#2 ... for Windows users of an app you'd need to be able to package
the app up with py2exe, which involves _including_ all the third-party
libraries called by the app.

HTH,
John
 
D

Diez B. Roggisch

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
 
P

pythonewbie

Where did I sound angry?


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...


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top