| Store | Cart

[Python-Dev] Does Zip Importer have to be Special?

From: Phil Thompson <p...@riverbankcomputing.com>
Thu, 24 Jul 2014 17:55:15 +0100
I have an importer for use in applications that embed an interpreter 
that does a similar job to the Zip importer (except that the storage is 
a C data structure rather than a .zip file). Just like the Zip importer 
I need to import my importer and add it to sys.path_hooks. However the 
earliest opportunity I have to do this is after the Py_Initialize() call 
returns - but this is too late because some parts of the standard 
library have already needed to be imported.

My current workaround is to include a modified version of _bootstrap.py 
as a frozen module that has the necessary steps added to the end of its 
_install() function.

The Zip importer doesn't have this problem because it gets special 
treatment - the call to its equivalent code is hard-coded and happens 
exactly when needed.

What would help is a table of functions that were called where 
_PyImportZip_Init() is currently called. By default the only entry in 
the table would be _PyImportZip_Init. There would be a way of modifying 
the table, either like how PyImport_FrozenModules is handled or how 
Inittab is handled.

...or if there is a better solution that I have missed that doesn't 
require a modified _bootstrap.py.

Thanks,
Phil
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com

Recent Messages in this Thread
Phil Thompson Jul 24, 2014 04:55 pm
Brett Cannon Jul 24, 2014 05:48 pm
Phil Thompson Jul 24, 2014 06:12 pm
Brett Cannon Jul 24, 2014 06:26 pm
Phil Thompson Jul 25, 2014 09:36 am
Nick Coghlan Jul 24, 2014 08:42 pm
Phil Thompson Jul 25, 2014 09:33 am
Nick Coghlan Jul 25, 2014 12:30 pm
Messages in this thread