Skip to main content

Create pre-solved environments for jupyterlite-pyodide-kernel with pyodide-lock

Project description

jupyterlite-pyodide-lock

Create pre-solved environments for jupyterlite-pyodide-kernel with pyodide-lock.

docs install build
docs install from pypi install from conda-forge build

View the full documentation on ReadTheDocs.

Installing

pip install jupyterlite-pyodide-lock

or:

mamba install -c conda-forge jupyterlite-pyodide-lock

Usage

Configure

Requirements

A number of ways to add requirements to the lock file are supported:

  • adding wheels in {lite_dir}/static/pyodide-lock
  • configuring specs as a list of PEP508 dependency specs
  • configuring packages as a list of
    • URLs to remote wheels that will be downloaded and cached
    • local paths relative to lite_dir of .whl files (or folders of wheels)
{
  "PyodideLockAddon": {
    "enabled": true,
    "specs": ["ipywidgets >=8.1,<8.2"],
    "packages": ["../dist/ipywidgets-8.1.2-py3-none-any.whl", "../dist"]
  }
}

Lockers

The Locker is responsible for starting a browser, executing micopip.install and micropip.freeze to try to get a viable lock file solution.

{
  "PyodideLockAddon": {
    "enabled": true,
    "locker": "browser"
  },
  "BrowserLocker": {
    "browser": "firefox",
    "headless": true,
    "private_mode": true,
    "temp_profile": true
  }
}

A convenience CLI options will show some information about detected browsers:

jupyter pyodide-lock browsers

Reproducible Locks

By configuring the lock date to a UNIX epoch timestamp, artifacts from a PyPI index newer than that date will be filtered out before a lock is attempted.

Combined with a fixed pyodide_url archive, this should prevent known packages and their dependencies from "drifting."

{
  "PyodideAddon":
    {
      "pyodide_url": f"https://github.com/pyodide/pyodide/releases/download/0.25.0/pyodide-core-0.25.0.tar.bz2",
    },
  "PyodideLockAddon": { "enabled": true, "lock_date_epoch": 1712980201 }
}

Alternately, this can be provided by environment variable:

JLPL_LOCK_DATE_EPOCH=$(date -u +%s) jupyter lite build
Getting a lock_date_epoch

As shown in the example above, date can provide this:

date -u +%s

Or python:

>>> from datetime import datetime, timezone
>>> int(datetime.now(tz=timezone.utc).timestamp())

... or git, for the last commit time of a file:

git log -1 --format=%ct requirements.txt

The latter approach, using version control metadata, is recommended, as it shifts the burden of bookkeeping to a verifiable source.

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

jupyterlite_pyodide_lock-0.1.1.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlite_pyodide_lock-0.1.1-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlite_pyodide_lock-0.1.1.tar.gz.

File metadata

File hashes

Hashes for jupyterlite_pyodide_lock-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1dbd7c86a09a56e5decdb8bf8a210fd45bd1f32074ba406a1c28c995ce96809
MD5 00fc4396dd7ba9875afc2197388e750f
BLAKE2b-256 5be874ce6a0054e66788843ad9e3832449958e23bc1ceb16ed22466a1cc6bcaf

See more details on using hashes here.

File details

Details for the file jupyterlite_pyodide_lock-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlite_pyodide_lock-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72ff81d6acaa66c7b1db3fd7a933140dd6a0dced8d2ec3513c258cdce14b2b88
MD5 64615a8073abbb3d3eada42a9760a430
BLAKE2b-256 cd9e4ea48c6481aee097e1fd2628ac183146234944ac180b257cc3180bd87ae5

See more details on using hashes here.

Supported by

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