Problem using bzr on Python program

John Arbash Meinel john at arbash-meinel.com
Mon Feb 12 15:05:19 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Seaton wrote:
> Actually I'm using
> 
> Bazaar (bzr) 0.10.0
> Using python interpreter:
> /home/ugrads/coms2003/cs3951/linux/installed/bin/python2.5
> Using python standard library:
> /home/ugrads/coms2003/cs3951/linux/installed/lib/python2.5
> Using bzrlib:
> /home/ugrads/coms2003/cs3951/linux/installed/lib/python2.5/site-packages/bzrlib
> 
> 
> with
> 
> Python 2.5 (r25:51908, Sep 26 2006, 14:51:52)
> 
> on Linux.
> 
> If it's a known bug is there a workaround?
> 
> Thanks
> 
> Chris Seaton

I haven't seen the bug on Linux, but the general case is when 'sys.path'
somehow starts to include '.' The old bug that Alexander is mentioning,
was a case where on Windows site.py would end up including '', which
then gets translated through os.abspath() to whatever the current
working directory is.

The only difficulty is that we usually do what the path where the 'bzr'
script resides to be included (since this allows you to simply run out
of source without installing).

You might try something like

echo -n 'import sys\nprint sys.path\n'> mytest.py

And then you can run that from different directories like:

python mytest.py

and


cd ..
python test/mytest.py

In both cases you should see that the "test" directory is in your path,
but in the second case the current working directory should not be.

- From there, it is just a matter of tracking down who is putting the cwd
into your path. One place to look is in lib/python2.5/site.py

That file is pretty much always imported, and at the end it calls
'main()' which does some setup of python.

One thing you might try is to just put "print sys.path" before and after
the main() call. Which should help to see if that is the point where
things are getting setup improperly.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0IIvJdeBCYSNAAMRAgvcAJ4oBRpGgkAfJPDXvQH2HYLoTBby+QCgy9gS
pObOkYgLstBhIseAPz4DH5c=
=Gim0
-----END PGP SIGNATURE-----



More information about the bazaar mailing list