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

ENH: A micropip.main() for %pip in Jupyter #82

Open
westurner opened this issue Sep 11, 2023 · 1 comment
Open

ENH: A micropip.main() for %pip in Jupyter #82

westurner opened this issue Sep 11, 2023 · 1 comment

Comments

@westurner
Copy link

westurner commented Sep 11, 2023

STORY: Users can use %pip to install with micropip in JupyterLite notebooks (so that notebooks with %pip will work with all Python Jupyter kernels)

%pip  # works in jupyter_console, jupyter notebook, jupyterlab, but not in JupyterLite
!pip  # doesn't work in pyodide (because there's no $SHELL; jupyterlite/jupyterlite#949)

# Works with the pyodide Jupyter kernel but not ipykernel or xeus-python:
import micropip
await micropip.install(["pandas",])

A main for %pip would need or could have at least:

def test_micropip_main_help_version(capsys):
    assert micropip.main(["-h"]) == 0    
    assert micropip.main(["--help"]) == 0
    captured = capsys.readouterr()
    assert "micropip" in captured.out

    assert micropip.main(["--version"]) == 0
    captured = capsys.readouterr()
    assert "micropip" in captured.out

def test_micropip_main_install(capsys):
    assert micropip.main(["install", "testpkg"]) == 0

##

def test_micropip_main_list(capsys):
    assert micropip.main(["list"]) == 0

def test_micropip_main_freeze(capsys):
    assert micropip.main(["freeze"]) == 0
@westurner westurner changed the title A micropip.__main__ for %pip in Jupyter A micropip.main() for %pip in Jupyter Sep 11, 2023
@westurner westurner changed the title A micropip.main() for %pip in Jupyter ENH: A micropip.main() for %pip in Jupyter Sep 11, 2023
@rth
Copy link
Member

rth commented Sep 11, 2023

STORY: Users can use %pip to install with micropip in JupyterLite notebooks

That's already the case https://jupyterlite.readthedocs.io/en/latest/howto/pyodide/packages.html#installing-packages-at-runtime,

%pip --help

usage: piplite [-h] [--verbose] [--quiet] [--requirements [REQUIREMENTS ...]]
               [--no-deps] [--pre]
               {help,install} [packages ...]

a pip-like wrapper for `piplite` and `micropip`

positional arguments:
  {help,install}        action to perform
  packages              package names (or wheel URLs) to install

options:
  -h, --help            show this help message and exit
  --verbose, -v         whether to print more output
  --quiet, -q           only show the minimum output
  --requirements [REQUIREMENTS ...], -r [REQUIREMENTS ...]
                        paths to requirements files
  --no-deps             whether dependencies should be installed
  --pre                 whether pre-release packages should be considered

although it doesn't support the other subcommand than install that micropip has, so maybe those could be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants