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


Download files

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

Source Distribution

backport_importlib-0...1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file backport_importlib-0...1.tar.gz.

File metadata

File hashes

Hashes for backport_importlib-0...1.tar.gz
Algorithm Hash digest
SHA256 6df9c805df87c59ef3e5d28bdd64995b1a103594489eabc6b5a3289013619fd1
MD5 32be7f327e81d49b8a2dc54103ab169a
BLAKE2b-256 59be4b1f09c557dd485f368b8df6e34ab414acf276b874a8d31840d50852234b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page