1 |
On 07-12-2007 16:34:14 +0100, Michael Haubenwallner wrote: |
2 |
> Hi, |
3 |
> |
4 |
> during bootstrap on native gentoo-linux I encountered this error: |
5 |
> |
6 |
> Traceback (most recent call last): |
7 |
> File "/eprefix/usr/lib/portage/bin/portageq", line 467, in ? |
8 |
> main() |
9 |
> File "/eprefix/usr/lib/portage/bin/portageq", line 450, in main |
10 |
> except portage.exception.PermissionDenied, e: |
11 |
> AttributeError: 'module' object has no attribute 'exception' |
12 |
> |
13 |
> This is because portageq tries to 'import portage', and only if it |
14 |
> fails, it prepends sys.path with "/eprefix/usr/lib/portage/pym". |
15 |
> |
16 |
> Prepending sys.path unconditionally helps here, because it accidentally |
17 |
> imported another portage: |
18 |
> |
19 |
> --- usr/lib/portage/bin/portageq.orig 2007-12-07 16:14:26.768371000 +0100 |
20 |
> +++ usr/lib/portage/bin/portageq 2007-12-07 16:14:48.689741000 +0100 |
21 |
> @@ -434,14 +434,11 @@ |
22 |
> sys.stderr.flush() |
23 |
> sys.exit(os.EX_USAGE) |
24 |
> os.environ["ROOT"] = sys.argv[2] |
25 |
> + from os import path as osp |
26 |
> + sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) |
27 |
> + global portage |
28 |
> + import portage |
29 |
> try: |
30 |
> - global portage |
31 |
> - try: |
32 |
> - import portage |
33 |
> - except ImportError: |
34 |
> - from os import path as osp |
35 |
> - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) |
36 |
> - import portage |
37 |
> if uses_root: |
38 |
> sys.argv[2] = portage.root |
39 |
> retval = function(sys.argv[2:]) |
40 |
> |
41 |
> IMO having portage-provided "executables" (like emerge (does it?), |
42 |
> portageq, ...) relying on PYTHONPATH to "import portage" correctly is a |
43 |
> pain - not only in prefix: think of calling /usr/bin/portageq (the |
44 |
> "native" one) while prefix' PYTHONPATH is set up in environment... |
45 |
|
46 |
Hmmm... this needs some thinking. I believe the portage code was/is |
47 |
already set up in such a way that it could do without a patched python |
48 |
to have portage's paths in PYTHONPATH. |
49 |
|
50 |
However, portage /does/ record which python it wants to use, so |
51 |
eventually it gets the "correct" python libraries when NOT using |
52 |
PYTHONPATH. |
53 |
|
54 |
|
55 |
-- |
56 |
Fabian Groffen |
57 |
Gentoo on a different level |
58 |
-- |
59 |
gentoo-alt@g.o mailing list |