[Python-Dev] Import redesign [LONG]
Gordon McMillan
gmcm@hypernet.com
Thu, 2 Dec 1999 18:15:50 -0500
[Guido]
big snip
> Note that the interpretation of __file__ could be problematic.
> To what value do you set __file__ for a module loaded from a zip
> archive?
I just left it alone (ie, as it was when I picked up the .pyc).
Turns out OK, because then when the end user files a bug
report, the developer can track it down.
> Note: I looked at the doc string for get_code() and I don't
> understand what the difference is between the modname and fqname
> arguments. If I write "import foo.bar", what are modname and
> fqname?
As I recall:
import foo.bar
-> get_code(None, 'foo', 'foo') # returns foo
-> get_code(<self>, 'bar', 'foo.bar')
> Why are both present?
I think so the importer can choose between being tree
structured or flat.
> I'd like to see a description of how someone like Jim A would
> build a single-file application using the new mechanism. This
> could completely replace freeze. (Freeze currently requires a C
> compiler; that's bad.)
I have something working for Linux now. I froze exceptions.py.
I hacked getpath.c so prefix = exec_prefix = executable's
directory and the starting path is [prefix]. Although I did it
differently, you could regard imputil.py and archive.py as
frozen, too. (On WIndows it's somewhat different, because the
result uses the stock python15.dll.) This somewhat
oversimplifies; and I haven't really thought out all the ways
people might try to use sym links. I'm inclined to think the
starting path should contain both the executable's real
directory and the sym link's directory.
> .... I do withdraw the composition
> requirement though.
Hooray!
- Gordon