Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --index-urls CLI flag for pip-install magics #166

Open
agriyakhetarpal opened this issue Feb 5, 2025 · 3 comments · May be fixed by #169
Open

Add a --index-urls CLI flag for pip-install magics #166

agriyakhetarpal opened this issue Feb 5, 2025 · 3 comments · May be fixed by #169
Assignees
Labels
enhancement New feature or request

Comments

@agriyakhetarpal
Copy link
Member

Problem

piplite supports passing a string or a list of strings of index URLs

index_urls: list[str] | str | None = None,

but it does not yet provide a CLI flag for them, so it is currently not possible to write commands %pip install numpy --index-urls https://anaconda.org/scientific-python-nightly-wheels/simple, as extra indices are/will be ignored and NumPy 2.0.2 from the Pyodide distribution is installed instead.

Proposed Solution

Extend https://github.com/jupyterlite/pyodide-kernel/blob/36aedb97d38cf283df8c3b0d65d7d6b8e575f0ab/packages/pyodide-kernel/py/piplite/piplite/cli.py to have a simple --index-urls option that is passed to piplite.py, at first. It could be extended to --index-url or --extra-index-url options later if and when such a change is brought upstream in micropip.

Additional context

xref: pyodide/pyodide#4898 (comment), as I've been meaning to test out the rollout of CORS headers for the Anaconda.org PyPI-like index through piplite, but I found I was unable to do so, while micropip works.

@agriyakhetarpal agriyakhetarpal added the enhancement New feature or request label Feb 5, 2025
@agriyakhetarpal
Copy link
Member Author

I'm happy to assign this to myself, and volunteer to work on it next week :D

@agriyakhetarpal agriyakhetarpal self-assigned this Feb 5, 2025
@agriyakhetarpal agriyakhetarpal changed the title Add a --index_urls CLI flag for pip-install magics Add a --index-urls CLI flag for pip-install magics Feb 6, 2025
@jtpio
Copy link
Member

jtpio commented Feb 6, 2025

I'm happy to assign this to myself, and volunteer to work on it next week :D

Thanks for volunteering!

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 6, 2025

Sure, that's a fine one to support. In general, when adding features to piplite, I would suggest:

{
  "jupyter-lite-schema-version": 0,
  "jupyter-config-data": {
    "appName": "JupyterLite Pyodide Kernel",
    "litePluginSettings": {
      "@jupyterlite/pyodide-kernel-extension:kernel": {
        "pipliteInstallDefaultOptions": {
          "indexUrls": ["http://..."]
        }
      }
    }
  }
}

Of note, until micropip 0.9.0+ lands in a pyodide release, there will be some fairly surprising behavior with under-specified installs, or %pip calls that occur in the same cell as imports due to the auto-import behavior. So:

%pip install thing-i-want-but-also-in-pyodide -i http://wherever
import some_thing_provided_by_that_package

vs

%pip install thing-i-want-but-also-in-pyodide -i http://wherever

and then

import some_thing_provided_by_that_package

Custom indexes are not included in this, as no upstream list of wheels provide importable names, to my knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants