Skip to main content

A script to backport the full importlib to 2.x

Project description

Introduced in Python 3.1, the importlib package provides a pure Python implementation of the import machinery. It is also available on PyPI as a [very] watered down backport.

The backport_importlib package provides a script that will backport the full importlib package to 2.x. Keep in mind that the backport is quite naive and likely incomplete. However, it passes the rudimentary tests included in the script.

The script is optparse-based and the “-h” flag should be sufficient to see how to use it. For information on how to use importlib, please refer to the current 3.x stdlib documentation. The script will update the importlib modules in-place, and will not install importlib for you. Also, you have to provide your own copy of the 3.x importlib, which you can get from hg.python.org/cpython (under Lib).

If you find cases where the backport could be improved please let me know. Also, it probably won’t work for Python earlier than 2.4, so keep that in mind.

One last thing. A big reason that importlib was not released on PyPI as a full backport was to encourage adoption of 3.x. I stand with Brett on that choice. This tool is meant for the desparate only. In truth, importlib provides very little that you don’t already have in the 2.x import machinery, so if you think you need it you’re probably wrong.

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
backport_importlib-0...1.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page