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
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to