[gobolinux-users] $pythonpath

giamby at infinito.it giamby at infinito.it
Thu Nov 29 06:51:08 NZDT 2007


On Wed, 28 Nov 2007 15:35:43 -0200
  "Hisham Muhammad" <hisham.hm at gmail.com> wrote:
> On Nov 27, 2007 6:26 PM, Carlo Calica <carlo at calica.com> 
>wrote:
>> On 11/14/07, Giambattista Bloisi <giamby at infinito.it> 
>>wrote:
>> >
>> > My problem was yet another I wanted python to scan for 
>>pth file that were in
>> > /System/Links/Libraries/python2.5/site-packages/ 
>>because some python modules (PyGObject)
>> > installed there .pth files in the hope they were 
>>actually scanned.
>> > I found that I could scan additional path for pth 
>>files by adding a line of the
>> > following form to gobolinux.pth:
>> > import site; 
>>site.addsitedir('/System/Links/Libraries/python2.5/site-packages/', 
>>set())
>> >
>> > This should be ok with docs and future versions of 
>>python as site doc says that lines
>> > starting with "import " are actually executed.
>> >
>> > I think that this could be a final solution for 
>>gobolinux distro. In this way when you have
>> > to add a dir in the search path all you have to do in 
>>the recipe is to add a .pth file in
>> > the appropriate Resources subdir. It is then symlinked 
>>to
>> > 
>>/System/Links/Libraries/python<major.minor>/site-packages/ 
>>and it works as we registered this path for pth file 
>>scanning.
>> >
>>
>> I've had time problem countless times.  I usually brute 
>>force it by
>> adding a symlink in /Programs/Python/.../.../ but this 
>>is much better.
>>  Could this be added to the Python recipe?
>>
>> add to gobolinux.pth
>> import site; 
>>site.addsitedir('/System/Links/Libraries/python2.5/site-packages/',
>> set())
>>
>> Anyone see any problems doing this?
> 
> Mmm, I'm not sure if I got it.
> 
> My gobolinux.pth currently looks like this:
> 
> /System/Links/Libraries/python2.3/site-packages/
> /System/Links/Libraries/python2.4/site-packages/
> /System/Links/Libraries/python2.5/site-packages/
> 
> Are you suggesting for it to look like this? (paths 
>mixed with Python code?)
> 
> /System/Links/Libraries/python2.3/site-packages/
> /System/Links/Libraries/python2.4/site-packages/
> /System/Links/Libraries/python2.5/site-packages/
> import site; 
>site.addsitedir('/System/Links/Libraries/python2.5/site-packages/',set())

My suggestion was:
/System/Links/Libraries/python2.3/site-packages/
/System/Links/Libraries/python2.4/site-packages/
import site; 
site.addsitedir('/System/Links/Libraries/python2.5/site-packages/',set())

You do not need to list the dir put in addsitedir.

> In any case, if I do this, I get:
> 
> 'import site' failed; use -v for traceback
> 
> everytime I launch Python. Running 'import site' 
>directly from Python
> gives me a long stack trace, with the error:
> 
> RuntimeError: maximum recursion depth exceeded
> 
> I tried removing the other paths from the file, and 
>clearing the
> $PYTHONPATH variable, but I still get the same error. 
>Does anybody
> have any idea?

Which version of python are you using ?
I tried the conf above both with 2.5 and 2.5.1 and it 
works fine.

Perhaps the recursion is caused by a .pth file inside 
/System/Links/Libraries/python2.5/site-packages/, but 
site.py should already have code to prevent this.


 
--------------------------------------------------------------------------
Hai tempo fino a dicembre per azzerare i costi di attivazione:
da casa o dall'ufficio naviga con la qualità di Infinito ADSL
(www.infinito.it/adsl)


More information about the gobolinux-users mailing list