[Python-Dev] Writing importers and path hooks (original) (raw)

Paul Moore p.f.moore at gmail.com
Wed Mar 27 23:59:55 CET 2013


On 27 March 2013 21:19, Bradley M. Froehle <brad.froehle at gmail.com> wrote:

I implemented just such a path hook ---- zipimporter plus the magic required for C extensions --- as a challenge to myself to learn more about the Python import mechanisms.

See https://github.com/bfroehle/pydzipimport.

Apologies for hijacking the thread, but it's interesting that you implemented your hook like this. I notice that you didn't use any of the importlib functionality in doing so. Was there a particular reason? I ask because a few days ago, I was writing a very similar importer, as I wanted to try a proof of concept importer based on the new importlib stuff (which is intended to make writing custom importers easier), and I really struggled to get something working.

It seems to me that the importlib documentation doesn't help much for people trying to import path hooks. But it might be just me. Does anyone have an example of a simple importlib-based finder/loader? That would be a huge help for me. In return for any pointers, I'll look at putting together a doc patch to clarify how to use importlib to build your own path hooks :-)

Thanks, Paul



More information about the Python-Dev mailing list