Can I build a single file containing all the contents of LIB?
Clarence Gardner
clarence at netlojix.com
Thu Jun 15 10:34:46 EDT 2000
On Thu, 15 Jun 2000, Warren Postma wrote:
>I have an embedded system which has no support for long filenames. It's also
>a pain to upload the whole LIB subdirectory to this system. The embedded
>system has a FAT filesystem and only supports 8 character filenames with a 3
>character extension. The first problem then is with the "exceptions.py" and
>from there on. Since my system recompiles for both native NT/Win32 and
>embedded mode, what I would ideally like to do is have a python script
>"bundle up" the standard Python library into a file, and then just upload
>that bundle. Then I would like it if python would search the \LIB directory
>FIRST for xxx.py and if not found, then search in the compressed (or not)
>file for it. I would like the file to be separate from the executable, not
>linked in, so I can change the python library without recompiling the
>executable.
>
You could probably write your own importing function which would
use __import__ rather than import, and in your embedded system would
map the module name to your short-named copy of the normally long-named
file before applying __import__ to it. Of course, you want to bind the module
thus imported to the actual module name rather than the short file name.
For example (totally untested code)
def myimport(ModuleName):
ModuleName = ModuleMap.get(ModuleName, ModuleName)
return __import__(ModuleName)
exceptions = myimport('exceptions')
More information about the Python-list
mailing list