[Distutils] Re: Add multiple frozen modules

Gordon McMillan gmcm@hypernet.com
Fri, 23 Jul 1999 16:45:34 -0500


James C. Ahlstrom wrote:

> I published a proposed library file format here on distutils
> and it is described in the doc strings.  But I didn't describe
> why I didn't use Greg's nor Gordon's format.  Both formats
> remove the 8-byte .pyc header.  But import.c validates this
> header for .pyc files and it should be retained. 

Why? So import.c can try to recompile from non-existant source?

If you let Greg or me build the archive, you'll find that the 
compiles get done if they're needed. Then the package contains a 
python and .pyc's that match that version.

With or without a check, a mismatch will produce an ugly mess.

> There was no
> file source information, but a user will want to print out the
> file names in the library.  

If they want to, the can get the name from the module's __importer__ 
attribute. They have everything they need to call archive.contents(), 
too, (if you're letting them get to an interpreter prompt).

> Greg's format could not be appended to
> another file.  Gordon can build the library onto another file with a
> program, but can not append the same file to different programs. 

Um, you mean because there's a "os.remove()" in Builder.py?

Builder.py is mostly concerned with parsing the config file and 
determining dependencies. The actual archive building is done by the 
archive class, with some utility functions in archivebuilder.py.

> The changes to import.c add another PY_LIBRARY import method
> (like PY_SOURCE, PY_COMPILED, etc.) and is programmed in a
> parallel fashion.  The code may be a bit rough but it is
> sufficient to get an idea.

I realize you don't like having to have four .py files in the current 
directory. I don't like messing with python internals, especially 
when (among other things) you can use this to distribute a stripped 
down but otherwise standard python.

In addition, both Greg & I are hoping (with some encouraging signs) 
that his imputil will attain sanctified status, which would probably 
mean that something like this could be done with just one 'extra' 
file.

But in the meantime, are you sure you can't get the same effect by 
using normal embedding techniques in the .exe (ie, instead of just 
calling Py_Main?). (Well, not quite normal techniques, since you have 
to use GetProcAddress).

> I am going away on vacation tomorrow, so I really hope all
> this works OK.  I will catch up on all your comments when I
> get back.

Have a good time.

- Gordon