Skip to main content

Import hook for Pyodide

Project description

pyodide-importer

Pyodide + external file import support

Installation

Inside Pyodide:

import micropip
await micropip.install("pyodide-importer")

Basic Usage

from pyodide_importer import register_hook
register_hook("<Base URL where python scripts are in>")
import external_module

Example

import micropip
await micropip.install("pyodide-importer")
from pyodide_importer import register_hook
register_hook("https://raw.githubusercontent.com/ryanking13/pyodide-importer/main/test_modules/")

# https://raw.githubusercontent.com/ryanking13/pyodide-importer/main/test_modules/file_module.py
import file_module
file_module.hello()

# https://raw.githubusercontent.com/ryanking13/pyodide-importer/main/test_modules/regular_module/__init__.py
import regular_module
regular_module.hello()

Advanced Usage

Whitelisting modules to import

Whitelisting modules will prevent from generating redundant HTTP requests when looking for not existing modules.

register_hook(
    "<Base URL where python scripts are in>",
    modules=["module1", "module2"]
)

Changing path where modules will be downloaded

download_path option changes the path where modules will be downloaded inside the virtual file system, default is set to the current working directory.

register_hook(
    "<Base URL where python scripts are in>",
    download_path="/path/to/be/downloaded",
)

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

pyodide-importer-0.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

pyodide_importer-0.0.2-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyodide-importer-0.0.2.tar.gz.

File metadata

  • Download URL: pyodide-importer-0.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for pyodide-importer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5857250a514e1261204672af8f09d2896e0e7d6311cc35b2428ef86fce0ee750
MD5 86136daef4dbbc41449ca85762cbb008
BLAKE2b-256 37a0fc5ddffc05bd405c0fc12908e2037e24fb480dc92a31b96c37dd7305a114

See more details on using hashes here.

File details

Details for the file pyodide_importer-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pyodide_importer-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for pyodide_importer-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 46797ca55eee47ec82a3083914b6cb21725eced3f45bffbde8d507b5e4443ddf
MD5 8e1d42e4e923d6f990feda7fc7e85424
BLAKE2b-256 3b6d5ae3f6d857949a6a4515164ed1868f3a618da5d6ad22061ecc0bd3d2c0f5

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