Skip to main content

Helps import Python extensions from memory, e.g. extensions from Zip files or Web.

Project description

memimport for Python 3

operating system Python implementation Python versions licenses development status
latest tag build status latest version package format monthly downloads

memimport is a part of py2exe, which helps import Python extensions from memory, e.g. extensions from Zip files or Web.

This repo via CI to build it as Python extensions, beacause the original has been built into the py2exe runstubs, only run with script, no REPL.

Development of memimport is hosted here: https://github.com/SeaHOH/memimport.
Development of py2exe is hosted here: https://github.com/py2exe/py2exe.

Installation

pip install memimport

Usage

import zipextimporter
import sys

sys.path.insert(0, 'path/to/libs.zip')

then

zipextimporter.install()            # default, prefer `hook=False`, `hook=True` as fallback

or

zipextimporter.install(hook=False)  # better compatibility, monkey patch `zipimport.zipimporter`
                                    # equal to empty argument, `hook=True` as fallback

or

zipextimporter.install(hook=True)   # not recommend, install to `sys.path_hooks`

then

import ext_mod_in_zip      # now, support __init__.pyd in packages

ext_mod_in_zip             # <module 'ext_mod_in_zip' from 'path\\to\\libs.zip\\ext_mod_in_zip\\__init__.pyd'>
ext_mod_in_zip.__file__    # 'path\\to\\libs.zip\\ext_mod_in_zip\\__init__.pyd'>
ext_mod_in_zip.__loader__  # <ZipExtensionImporter object 'path\to\libs.zip\'>

import py_mod_in_zip

py_mod_in_zip              # <module 'py_mod_in_zip' from 'path\\to\\libs.zip\\py_mod_in_zip\\__init__.py'>
py_mod_in_zip.__file__     # 'path\\to\\libs.zip\\py_mod_in_zip\\__init__.py'>
py_mod_in_zip.__loader__   # <zipimporter object 'path\to\libs.zip\'>

More usage see source or use help function.

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

memimport-0.13.0.0.post7.tar.gz (40.0 kB view hashes)

Uploaded Source

Built Distributions

memimport-0.13.0.0.post7-cp311-cp311-win_amd64.whl (24.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

memimport-0.13.0.0.post7-cp311-cp311-win32.whl (23.6 kB view hashes)

Uploaded CPython 3.11 Windows x86

memimport-0.13.0.0.post7-cp310-cp310-win_amd64.whl (24.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

memimport-0.13.0.0.post7-cp310-cp310-win32.whl (23.6 kB view hashes)

Uploaded CPython 3.10 Windows x86

memimport-0.13.0.0.post7-cp39-cp39-win_amd64.whl (24.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

memimport-0.13.0.0.post7-cp39-cp39-win32.whl (23.6 kB view hashes)

Uploaded CPython 3.9 Windows x86

memimport-0.13.0.0.post7-cp38-cp38-win_amd64.whl (24.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

memimport-0.13.0.0.post7-cp38-cp38-win32.whl (23.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

memimport-0.13.0.0.post7-cp37-cp37m-win_amd64.whl (24.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

memimport-0.13.0.0.post7-cp37-cp37m-win32.whl (23.5 kB view hashes)

Uploaded CPython 3.7m Windows x86

memimport-0.13.0.0.post7-cp36-cp36m-win_amd64.whl (19.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

memimport-0.13.0.0.post7-cp36-cp36m-win32.whl (17.9 kB view hashes)

Uploaded CPython 3.6m Windows x86

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