Re: changing sys.path

2012-02-10 Thread Andrea Crotti
On 02/10/2012 04:00 PM, Peter Otten wrote: Sorry, you didn't mention that in the post I responded to and I didn't follow the thread closely. I found a description for declare_namespace() at http://peak.telecommunity.com/DevCenter/PkgResources but the text explaining the function is completely u

Re: changing sys.path

2012-02-10 Thread Peter Otten
Andrea Crotti wrote: > On 02/10/2012 03:27 PM, Peter Otten wrote: >> The package a will be either a.c/a/ or a.b/a/ depending on whether >> a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not >> contain a c submodule or subpackage. > > > I would agree if I didn't have this declar

Re: changing sys.path

2012-02-10 Thread Peter Otten
Peter Otten wrote: > If it's a.c/a, that does not contain a c submodule or subpackage. Sorry, I meant a.b/a -- http://mail.python.org/mailman/listinfo/python-list

Re: changing sys.path

2012-02-10 Thread Andrea Crotti
On 02/10/2012 03:27 PM, Peter Otten wrote: The package a will be either a.c/a/ or a.b/a/ depending on whether a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not contain a c submodule or subpackage. I would agree if I didn't have this declaration __import__('pkg_resources').

Re: changing sys.path

2012-02-10 Thread Peter Otten
Andrea Crotti wrote: > Ok now it's getting really confusing, I tried a small example to see > what is the real behaviour, > so I created some package namespaces (where the __init__.py declare the > namespace package). > >/home/andrea/test_ns: >total used in directory 12 available 5655372

Re: changing sys.path

2012-02-10 Thread Andrea Crotti
On 02/10/2012 03:06 PM, Dave Angel wrote: Yes, you've got periods in your directory names. A period means something special within python, and specifically within the import. When you say from a.c import api You're telling it:from package a get module c, and from there impoort the sy

Re: changing sys.path

2012-02-10 Thread Dave Angel
On 02/10/2012 09:51 AM, Andrea Crotti wrote: Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 565

Re: changing sys.path

2012-02-10 Thread Andrea Crotti
Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 5655372 drwxr-xr-x 3 andrea andrea 4096 F

Re: changing sys.path

2012-02-10 Thread Dave Angel
On 02/10/2012 08:08 AM, Andrea Crotti wrote: I think I finally located the issue with the sys.path extension. The problem is that I have many namespace directories, for example lib: - sub1 - sub2 lib: - sub3 - sub4 But to have everything working I had lib.sub3 in easy-install.pth. Now i

Re: changing sys.path

2012-02-10 Thread Andrea Crotti
I think I finally located the issue with the sys.path extension. The problem is that I have many namespace directories, for example lib: - sub1 - sub2 lib: - sub3 - sub4 But to have everything working I had lib.sub3 in easy-install.pth. Now if I try to add something else to the path it d

Re: changing sys.path

2012-02-08 Thread John Nagle
On 2/1/2012 8:15 AM, Andrea Crotti wrote: So suppose I want to modify the sys.path on the fly before running some code which imports from one of the modules added. at run time I do sys.path.extend(paths_to_add) but it still doesn't work and I get an import error. Do import sys fi

Re: changing sys.path

2012-02-02 Thread Tim Roberts
Andrea Crotti wrote: > >So suppose I want to modify the sys.path on the fly before running some code >which imports from one of the modules added. > >at run time I do >sys.path.extend(paths_to_add) > >but it still doesn't work and I get an import error. Are you actually adding multiple paths? On

Re: changing sys.path

2012-02-02 Thread jmfauth
On 2 fév, 11:03, Andrea Crotti wrote: > On 02/02/2012 12:51 AM, Steven D'Aprano wrote: > > > > > On Wed, 01 Feb 2012 17:47:22 +, Andrea Crotti wrote: > > >> Yes they are exactly the same, because in that file I just write exactly > >> the same list, > >> but when modifying it at run-time it do

Re: changing sys.path

2012-02-02 Thread Andrea Crotti
On 02/02/2012 12:51 AM, Steven D'Aprano wrote: On Wed, 01 Feb 2012 17:47:22 +, Andrea Crotti wrote: Yes they are exactly the same, because in that file I just write exactly the same list, but when modifying it at run-time it doesn't work, while if at the application start there is this file

Re: changing sys.path

2012-02-01 Thread Steven D'Aprano
On Wed, 01 Feb 2012 17:47:22 +, Andrea Crotti wrote: > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That

Re: changing sys.path

2012-02-01 Thread Tim Delaney
On 2 February 2012 04:47, Andrea Crotti wrote: > > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That's what r

Re: changing sys.path

2012-02-01 Thread Rick Johnson
On Feb 1, 10:15 am, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these p

Re: changing sys.path

2012-02-01 Thread Andrea Crotti
On 02/01/2012 05:13 PM, Eric Snow wrote: On Wed, Feb 1, 2012 at 9:15 AM, Andrea Crotti wrote: So suppose I want to modify the sys.path on the fly before running some code which imports from one of the modules added. at run time I do sys.path.extend(paths_to_add) but it still doesn't work and

Re: changing sys.path

2012-02-01 Thread jmfauth
On 1 fév, 17:15, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these path

changing sys.path

2012-02-01 Thread Andrea Crotti
So suppose I want to modify the sys.path on the fly before running some code which imports from one of the modules added. at run time I do sys.path.extend(paths_to_add) but it still doesn't work and I get an import error. If I take these paths and add them to site-packages/my_paths.pth everythi