Skip to main content

Python import utilities

Project description

Python utility for keeping track of packages that were imported and isolating imports.

Install

pip install pylibimp

Example

Normal Import Hook to save an imports dependent modules

import pylibimp

with pylibimp.SaveBuiltinsImportHook() as imp:
    import pylibimp
    import urllib3

modules = imp.get_modules()
assert 'pylibimp' in modules
assert 'urllib3' in modules

Import a module but keep the original system

import sys
import pylibimp

modules = sys.modules.copy()
with pylibimp.original_system():
    import urllib3

assert 'urllib3' not in modules

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

pylibimp-1.0.1.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

pylibimp-1.0.1-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

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