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.

Installing

This package is not yet released. See CONTRIBUTING.md for development.

pip install jupyterlite-pyodide-lock

or mamba/conda:

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)
# examples/jupyter_lite_config.json
{ 'PyodideLockAddon': { 'enabled': true, 'specs': [
          # pep508 spec
          'ipywidgets >=8.1,<8.2',
        ], 'packages': [
          # a wheel
          '../dist/ipywidgets-8.1.2-py3-none-any.whl',
          # a folder of wheels
          '../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,
      # the default locker: uses naive a `subprocess.Popen` approach
      'locker': 'browser',
    }, 'BrowserLocker': {
      # requires `firefox` or `firefox.exe` on PATH
      '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 environemnt 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 approch, 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.0.tar.gz (28.8 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.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jupyterlite_pyodide_lock-0.1.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for jupyterlite_pyodide_lock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b35bb94f95982f18f681eed3dea17bf0af27363c39a31b084d59a1b00ecfbe2
MD5 ccda042e48c5d66aa19211f2573ba51e
BLAKE2b-256 c44341b0a448c6b6cca865055e7033da40f4bd86f19911baab52280eab077e3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jupyterlite_pyodide_lock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 042b178bd81011e30427f9cb15ce5b16188b5cfd53616ceb35e9765f264b3c4d
MD5 51c14a7a31e4ea24f24bfd7ae32b4242
BLAKE2b-256 3d6801358829bf99c4282572d96506438d2957af3d7fa367235113a68c478a86

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