[Python-Dev] importlib is now bootstrapped (and what that means) (original) (raw)

Eric Snow ericsnowcurrently at gmail.com
Fri Apr 20 17:02:14 CEST 2012


On Fri, Apr 20, 2012 at 7:54 AM, Eric V. Smith <eric at trueblade.com> wrote:

On 04/14/2012 02:12 PM, Brett Cannon wrote:

My multi-year project -- started in 2006 according to my blog -- to rewrite import in pure Python and then bootstrap it into CPython as the implementation of import() is finally over (mostly)! Maybe I'm missing something, but it seems that I need to run importlib.bootstrap.install(sys, imp) manually in order to make import be importlib's version. Is that not supposed to happen automatically?

In the default tip (3.3a2+), importlib.import is already bootstrapped, so you don't need mess with anything. As well, in any of the 3.x versions you can bind builtins.import to importlib.import.

If you are making changes to importlib (essentially, changes in Lib/importlib/_bootstrap.py), you must re-build (make) cpython in order for your changes to get pulled into the frozen copy of importlib. Until you do that, the built-in import machinery will be the one that existed before your changes. You could also re-bind builtins.import to try out the changes without having to re-build, but ultimately your changes will have to get frozen (into Python/importlib.h) and will be part of the commit of your changes to importlib.

Likely you already know all this, but just in case... :)

-eric



More information about the Python-Dev mailing list