Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
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 platforms. Google was not a good friend on this, so I am very interested on how you implement such a function. Cheers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 20 jan, 12:20, Christian Heimes <[EMAIL PROTECTED]> wrote: > pythonewbie wrote: > > I am stucked on creating a function to get the Python install > > directory (and site-packages directory) with a 100% reliable method... > > Only one method is 100% reliable: > > try: > import yourextension > except ImportError: > available = False > else: > available = True > > Christian Hi Christian, OK thanks, interesting to detect if an extension is available or not. But for different reasons I also want to get the absolute path of Python install directory (not only the executable under Linux) and site-packages directory. How could I proceed ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 20 jan, 19:50, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie schrieb: > > > > > On 20 jan, 12:20, Christian Heimes <[EMAIL PROTECTED]> wrote: > >> pythonewbie wrote: > >>> I am stucked on creating a function to get the Python install > >>> directory (and site-packages directory) with a 100% reliable method... > >> Only one method is 100% reliable: > > >> try: > >> import yourextension > >> except ImportError: > >> available = False > >> else: > >> available = True > > >> Christian > > > Hi Christian, > > > OK thanks, interesting to detect if an extension is available or not. > > > But for different reasons I also want to get the absolute path of > > Python install directory (not only the executable under Linux) and > > site-packages directory. > > > How could I proceed ? > > Maybe sys.path is a starter? > > Diez Yes, it is, but my problem is that I am not sure to find the information I need at the same position of the list generated by sys.path. I explain, for Win32, I find install directory using sys.path[6] and site-package directory using sys.path[7], for Linux I find install directory using sys.path[2] and site-package directory using sys.path[6]. For my tests, I have used XP Pro and Ubuntu Gutsy. I am not sure to find these information at the same position in the sys.path list using Win9x, Win2k, Ubuntu Dapper, Redhat FC6, FreeBSD and using Python v2.1 2.2 2.3 etc ? This why I'm asking experienced programmers of this usenet group for advices. -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 20 jan, 20:59, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie schrieb: > > > > > On 20 jan, 19:50, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> pythonewbie schrieb: > > >>> On 20 jan, 12:20, Christian Heimes <[EMAIL PROTECTED]> wrote: > >>>> pythonewbie wrote: > >>>>> I am stucked on creating a function to get the Python install > >>>>> directory (and site-packages directory) with a 100% reliable method... > >>>> Only one method is 100% reliable: > >>>> try: > >>>> import yourextension > >>>> except ImportError: > >>>> available = False > >>>> else: > >>>> available = True > >>>> Christian > >>> Hi Christian, > >>> OK thanks, interesting to detect if an extension is available or not. > >>> But for different reasons I also want to get the absolute path of > >>> Python install directory (not only the executable under Linux) and > >>> site-packages directory. > >>> How could I proceed ? > >> Maybe sys.path is a starter? > > >> Diez > > > Yes, it is, but my problem is that I am not sure to find the > > information I need at the same position of the list generated by > > sys.path. > > > I explain, for Win32, I find install directory using sys.path[6] and > > site-package directory using sys.path[7], for Linux I find install > > directory using sys.path[2] and site-package directory using > > sys.path[6]. > > > For my tests, I have used XP Pro and Ubuntu Gutsy. > > > I am not sure to find these information at the same position in the > > sys.path list using Win9x, Win2k, Ubuntu Dapper, Redhat FC6, FreeBSD > > and using Python v2.1 2.2 2.3 etc ? > > > This why I'm asking experienced programmers of this usenet group for > > advices. > > Sorry, I missed your first post. However, I don't see what your problem > actually is. If you want to look for any extension, you need to consider > whatever can be seen in the sys.path. So what do you care about the > order of them? > > Diez I just would like to know if I would ALWAYS find the install directory in sys.path[6] and site-packages directory in sys.path[7] on any Win32 platform and sys.path[2] and site-packages directory in sys.path[6] on any Linux platform. If the reply is : "YES you can be sure of it !" All would be great for me and I would be ready to create a script to detect with a reliable manner the installation dir. et site-packages dir. for all my Linux/Win32 Python apps. Thanks for your interest on this topic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 20 jan, 23:19, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > But for different reasons I also want to get the absolute path of > > Python install directory (not only the executable under Linux) and > > site-packages directory. > > The Python install directory is available as sys.prefix. The > site-packages directory is > sys.prefix+"lib/python"+x.y+"/site-packages (where x.y is from > sys.version_info). > > HTH, > Martin http://forum.ubuntu-fr.org/viewtopic.php?id=184199 >>> import distutils.sysconfig >>> distutils.sysconfig.get_python_lib() '/usr/lib/python2.5/site-packages' get_python_lib(plat_specific=0, standard_lib=0, prefix=None) 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'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 20 jan, 23:55, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie schrieb: > > > > > On 20 jan, 20:59, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> pythonewbie schrieb: > > >>> On 20 jan, 19:50, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >>>> pythonewbie schrieb: > >>>>> On 20 jan, 12:20, Christian Heimes <[EMAIL PROTECTED]> wrote: > >>>>>> pythonewbie wrote: > >>>>>>> I am stucked on creating a function to get the Python install > >>>>>>> directory (and site-packages directory) with a 100% reliable method... > >>>>>> Only one method is 100% reliable: > >>>>>> try: > >>>>>> import yourextension > >>>>>> except ImportError: > >>>>>> available = False > >>>>>> else: > >>>>>> available = True > >>>>>> Christian > >>>>> Hi Christian, > >>>>> OK thanks, interesting to detect if an extension is available or not. > >>>>> But for different reasons I also want to get the absolute path of > >>>>> Python install directory (not only the executable under Linux) and > >>>>> site-packages directory. > >>>>> How could I proceed ? > >>>> Maybe sys.path is a starter? > >>>> Diez > >>> Yes, it is, but my problem is that I am not sure to find the > >>> information I need at the same position of the list generated by > >>> sys.path. > >>> I explain, for Win32, I find install directory using sys.path[6] and > >>> site-package directory using sys.path[7], for Linux I find install > >>> directory using sys.path[2] and site-package directory using > >>> sys.path[6]. > >>> For my tests, I have used XP Pro and Ubuntu Gutsy. > >>> I am not sure to find these information at the same position in the > >>> sys.path list using Win9x, Win2k, Ubuntu Dapper, Redhat FC6, FreeBSD > >>> and using Python v2.1 2.2 2.3 etc ? > >>> This why I'm asking experienced programmers of this usenet group for > >>> advices. > >> Sorry, I missed your first post. However, I don't see what your problem > >> actually is. If you want to look for any extension, you need to consider > >> whatever can be seen in the sys.path. So what do you care about the > >> order of them? > > >> Diez > > > I just would like to know if I would ALWAYS find the install directory > > in sys.path[6] and site-packages directory in sys.path[7] on any Win32 > > platform and sys.path[2] and site-packages directory in sys.path[6] on > > any Linux platform. > > > If the reply is : "YES you can be sure of it !" > > > All would be great for me and I would be ready to create a script to > > detect with a reliable manner the installation dir. et site-packages > > dir. for all my Linux/Win32 Python apps. > > > Thanks for your interest on this topic. > > I doubt that you can say such things. You can even manipulate the path > at runtime. > > And I still don't understand WHY you want that? If you want > site-packages, why don't you loop through the paths until you find it? > > Diez Because the solution using distutils.sysconfig.get_python_lib() is very smart ! Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 00:09, John Machin <[EMAIL PROTECTED]> wrote:
> On Jan 21, 8:58 am, pythonewbie <[EMAIL PROTECTED]> wrote:
>
> > I just would like to know if I would ALWAYS find the install directory
> > in sys.path[6] and site-packages directory in sys.path[7] on any Win32
> > platform and sys.path[2] and site-packages directory in sys.path[6] on
> > any Linux platform.
>
> > If the reply is : "YES you can be sure of it !"
>
> No, you can't be sure of any such thing. In general in computing
> assuming a fixed position in a variable-length list is a nonsense.
>
> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.>>>
> import sys
> >>> from pprint import pprint as pp
> >>> pp([(x, p) for x, p in enumerate(sys.path)])
>
> [(0, ''),
> (1, 'c:\\python25\\lib\\site-packages\\setuptools-0.6c3-py2.5.egg'),
> (2, 'C:\\WINDOWS\\system32\\python25.zip'),
> (3, 'c:\\python25\\DLLs'),
> (4, 'c:\\python25\\lib'),
> (5, 'c:\\python25\\lib\\plat-win'),
> (6, 'c:\\python25\\lib\\lib-tk'),
> (7, 'c:\\python25'),
> (8, 'c:\\python25\\lib\\site-packages'),
> (9, 'c:\\python25\\lib\\site-packages\\win32'),
> (10, 'c:\\python25\\lib\\site-packages\\win32\\lib'),
> (11, 'c:\\python25\\lib\\site-packages\\Pythonwin')]
>
>
>
> Something like this might be more reliable:
>
> >>> import sys, re
> >>> for p in sys.path:
>
> ...m = re.match(r'(.*)[\\/][Ll]ib[\\/]site-packages$', p)
> ...if m:
> ... print m.group(1, 0)
> ... break
> ... else:
> ...raise Exception('Huh?')
> ...
> ('c:\\python25', 'c:\\python25\\lib\\site-packages')
>
>
>
> > All would be great for me and I would be ready to create a script to
> > detect with a reliable manner the installation dir. et site-packages
> > dir. for all my Linux/Win32 Python apps.
>
> You mentioned Python versions back to 2.1 earlier. However you
> evidently haven't bothered to start up Python 2.1 and look at
> sys.path:
>
> C:\junk>\python21\python
> Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on
> win32
> Type "copyright", "credits" or "license" for more information.>>> import sys;
> sys.path
>
> ['', 'C:\\junk', 'C:\\python21\\DLLs', 'C:\\python21\\lib', 'C:\
> \python21\\lib\\
> plat-win', 'C:\\python21\\lib\\lib-tk', 'C:\\python21']
>
>
>
> Before you rush out and re-invent the wheel, have a look at this:
>
> http://www.python.org/community/sigs/current/distutils-sig/
>
> You may like to re-ask your questions on the distutils mailing list.
>
> HTH,
> John
Hi John,
Thanks for your help and suggestions.
Your code is very interesting for the newbie that I am.
But I have not understood your two last suggestions...
As a newbie, I have asked usenet for help in order to get a easy/
convenient way to get the site-packages directory, and the best reply
I obtained, was to use the function
distutils.sysconfig.get_python_lib().
This function is a really good way to avoid to re-invent the wheel to
get what I wanted !
Cheers.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 05:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 20 Jan 2008 13:58:13 -0800 (PST), pythonewbie > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > I just would like to know if I would ALWAYS find the install directory > > in sys.path[6] and site-packages directory in sys.path[7] on any Win32 > > platform and sys.path[2] and site-packages directory in sys.path[6] on > > any Linux platform. > > Unlikely... > > >>> sys.path[6] > > 'E:\\Python24\\lib\\site-packages\\decoratortools-1.4-py2.4.egg'>>> > sys.path[2] > > 'E:\\Python24\\lib\\site-packages\\ctypes-1.0.1-py2.4-win32.egg'>>> sys.path > > ['', 'E:\\Python24\\lib\\site-packages\\pyopengl-3.0.0a5-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\ctypes-1.0.1-py2.4-win32.egg', > 'E:\\Python24\\lib\\site-packages\\sqlobject-0.7.6-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\celementtree-1.0.5_20051216-py2.4-win32.egg', > 'E:\\Python24\\lib\\site-packages\\configobj-4.4.0-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\decoratortools-1.4-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\ruledispatch-0.5a0.dev_r2306-py2.4-win32.egg', > 'E:\\Python24\\lib\\site-packages\\formencode-0.7.1-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\pastescript-1.3.4-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\elementtree-1.2.6_20050316-py2.4-win32.egg', > 'E:\\Python24\\lib\\site-packages\\simplejson-1.7.1-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\cherrypy-2.2.1-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\turbocheetah-0.9.5-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\turbojson-1.0-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\pyprotocols-1.0a0dev_r2302-py2.4-win32.egg', > 'E:\\Python24\\lib\\site-packages\\pastedeploy-1.3-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\paste-1.3-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\cheetah-2.0rc8-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\setuptools-0.6c6-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\turbogears-1.0.3.2-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\turbokid-1.0.2-py2.4.egg', > 'E:\\Python24\\lib\\site-packages\\kid-0.9.6-py2.4.egg', > 'e:\\python24\\lib\\site-packages\\scipy', > 'C:\\WINDOWS\\system32\\python24.zip', 'e:\\UserData\\Dennis Lee > Bieber\\My Documents', 'E:\\Python24\\DLLs', 'E:\\Python24\\lib', > 'E:\\Python24\\lib\\plat-win', 'E:\\Python24\\lib\\lib-tk', > 'E:\\Python24\\Lib\\site-packages\\pythonwin', 'E:\\Python24', > 'E:\\Python24\\lib\\site-packages', > 'E:\\Python24\\lib\\site-packages\\Numeric', > 'E:\\Python24\\lib\\site-packages\\PIL', > 'E:\\Python24\\lib\\site-packages\\win32', > 'E:\\Python24\\lib\\site-packages\\win32\\lib', > 'E:\\Python24\\lib\\site-packages\\wx-2.8-msw-unicode'] > > >>> os.environ["PATH"] > > 'E:\\Python24\\;C:\\GNAT\\bin;C:\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\PROGRA~1\\MySQL\\MySQL > Server 5.0\\bin;C:\\Program Files\\SciTE;C:\\Program > Files\\Java\\jre1.6.0_03\\bin;C:\\Program > Files\\Java\\jdk1.6.0_03\\bin;C:\\Program Files\\Common > Files\\Adobe\\AGL;C:\\MSSQL7\\BINN;c:\\PROGRA~1\\sdb\\programs\\bin;c:\\PROGRA~1\\sdb\\programs\\pgm;C:\\Tcl\\bin;C:\\Program > Files\\Common Files\\Roxio Shared\\DLLShared\\;C:\\Program Files\\Common > Files\\Roxio Shared\\9.0\\DLLShared\\;e:\\Python24\\Scripts;c:\\Regina' > > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ OK Denis Lee, I see now. I appreciate your clear and simple to understand reply. All posts on this topic, have been appreciated a lot... Thanks to all helpers. Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 09:53, pythonewbie <[EMAIL PROTECTED]> wrote:
> On 21 jan, 05:31, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Sun, 20 Jan 2008 13:58:13 -0800 (PST), pythonewbie
> > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> > > I just would like to know if I would ALWAYS find the install directory
> > > in sys.path[6] and site-packages directory in sys.path[7] on any Win32
> > > platform and sys.path[2] and site-packages directory in sys.path[6] on
> > > any Linux platform.
>
> > Unlikely...
>
> > >>> sys.path[6]
>
> > 'E:\\Python24\\lib\\site-packages\\decoratortools-1.4-py2.4.egg'>>>
> > sys.path[2]
>
> > 'E:\\Python24\\lib\\site-packages\\ctypes-1.0.1-py2.4-win32.egg'>>> sys.path
>
> > ['', 'E:\\Python24\\lib\\site-packages\\pyopengl-3.0.0a5-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\ctypes-1.0.1-py2.4-win32.egg',
> > 'E:\\Python24\\lib\\site-packages\\sqlobject-0.7.6-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\celementtree-1.0.5_20051216-py2.4-win32.egg',
> > 'E:\\Python24\\lib\\site-packages\\configobj-4.4.0-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\decoratortools-1.4-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\ruledispatch-0.5a0.dev_r2306-py2.4-win32.egg',
> > 'E:\\Python24\\lib\\site-packages\\formencode-0.7.1-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\pastescript-1.3.4-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\elementtree-1.2.6_20050316-py2.4-win32.egg',
> > 'E:\\Python24\\lib\\site-packages\\simplejson-1.7.1-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\cherrypy-2.2.1-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\turbocheetah-0.9.5-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\turbojson-1.0-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\pyprotocols-1.0a0dev_r2302-py2.4-win32.egg',
> > 'E:\\Python24\\lib\\site-packages\\pastedeploy-1.3-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\paste-1.3-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\cheetah-2.0rc8-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\setuptools-0.6c6-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\turbogears-1.0.3.2-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\turbokid-1.0.2-py2.4.egg',
> > 'E:\\Python24\\lib\\site-packages\\kid-0.9.6-py2.4.egg',
> > 'e:\\python24\\lib\\site-packages\\scipy',
> > 'C:\\WINDOWS\\system32\\python24.zip', 'e:\\UserData\\Dennis Lee
> > Bieber\\My Documents', 'E:\\Python24\\DLLs', 'E:\\Python24\\lib',
> > 'E:\\Python24\\lib\\plat-win', 'E:\\Python24\\lib\\lib-tk',
> > 'E:\\Python24\\Lib\\site-packages\\pythonwin', 'E:\\Python24',
> > 'E:\\Python24\\lib\\site-packages',
> > 'E:\\Python24\\lib\\site-packages\\Numeric',
> > 'E:\\Python24\\lib\\site-packages\\PIL',
> > 'E:\\Python24\\lib\\site-packages\\win32',
> > 'E:\\Python24\\lib\\site-packages\\win32\\lib',
> > 'E:\\Python24\\lib\\site-packages\\wx-2.8-msw-unicode']
>
> > >>> os.environ["PATH"]
>
> > 'E:\\Python24\\;C:\\GNAT\\bin;C:\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\PROGRA~1\\MySQL\\MySQL
> > Server 5.0\\bin;C:\\Program Files\\SciTE;C:\\Program
> > Files\\Java\\jre1.6.0_03\\bin;C:\\Program
> > Files\\Java\\jdk1.6.0_03\\bin;C:\\Program Files\\Common
> > Files\\Adobe\\AGL;C:\\MSSQL7\\BINN;c:\\PROGRA~1\\sdb\\programs\\bin;c:\\PROGRA~1\\sdb\\programs\\pgm;C:\\Tcl\\bin;C:\\Program
> > Files\\Common Files\\Roxio Shared\\DLLShared\\;C:\\Program Files\\Common
> > Files\\Roxio Shared\\9.0\\DLLShared\\;e:\\Python24\\Scripts;c:\\Regina'
>
> > --
> > WulfraedDennis Lee Bieber KD6MOG
> > [EMAIL PROTECTED] [EMAIL PROTECTED]
> > HTTP://wlfraed.home.netcom.com/
> > (Bestiaria Support Staff: [EMAIL PROTECTED])
> > HTTP://www.bestiaria.com/
>
> OK Denis Lee, I see now. I appreciate your clear and simple to
> understand reply.
>
> All posts on this topic, have been appreciated a lot... Thanks to all
> helpers.
>
> Cheers
Hi John Machin,
Your code :
>>> import sys, re
>>> for p in sys.path:
...m = re.match(r'(.*)[\\/][Ll]ib[\\/]site-packages$', p)
...if m:
... print m.group(1, 0)
... break
... else:
...raise Exception('Huh?')
...
Does not work on my PC : Traceback (most recent call last):
File "/home/eproust/john-machin_recup_rep_site-packages.py", line 9,
in
raise Exception('Huh?')
Exception: Huh?
Even if I remove all code below the else: part of the script...
-
Thanks for your advice to read :
http://www.python.org/community/sigs/current/distutils-sig/
Cheers
--
http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 10:34, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie > > > > > Because the solution using distutils.sysconfig.get_python_lib() is > > very smart ! > > 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, >>> sys.path ['', '/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'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 10:34, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > pythonewbie > > > > > Because the solution using distutils.sysconfig.get_python_lib() is > > very smart ! > > 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... -- http://mail.python.org/mailman/listinfo/python-list
Re: Linux/Win32 func. to get Python instdir (not exedir) + site-packages => extensions mgmt
On 21 jan, 11:49, "Diez B. Roggisch" <[EMAIL PROTECTED]> 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. -- http://mail.python.org/mailman/listinfo/python-list
