Skip to content

Support constraints in piplite #165

@bollwyvl

Description

@bollwyvl

Problem

micropip 0.9.0 was just released, which support constraints (e.g. iff package x is installed it must be version y or from URL z). This will be very helpful for jupyterlite site builders as the (likely filtered) output of pip list --format=freeze would get us a step closer to reproducible envs. These won't somehow magically participate in auto-import, as top-level names would still not be available.

When a version of pyodide is released which contains this (or a user builds a custom pyodide distribution containing it), piplite and the %pip magic won't yet support them, and as a "major" version upgrade containing other significant changes (such as vendoring packaging), might just break.

Proposed Solution

  • add constraints to various wrapper signatures around micropip.install(..., constraints=[]) and set_constraints
  • add %pip install -c/--constraint
    • for pip, this is always a file, but we already support -r/--requirements, so the existing logic should work
  • add a way to set default constraints at build time
    • discussed previously, adding a pipliteInstallOptions could allow for setting all the (non-dependency) options:
      {
        "pipliteInstallOptions": {
          "constraints": [
            "ipywidgets ==8.1.2"
          ],
          "index_urls": [],
          "keep_going": true
        }
      }

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions