From f193468f764141f4f6e99dddbbb4375370bbd55b Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 5 Jul 2023 17:58:19 -0700 Subject: [PATCH] llm install -e/--editable option --- docs/help.md | 7 ++++--- llm/cli.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/help.md b/docs/help.md index 99e17e2..9528b3f 100644 --- a/docs/help.md +++ b/docs/help.md @@ -263,13 +263,14 @@ Options: ``` ### llm install --help ``` -Usage: llm install [OPTIONS] PACKAGES... +Usage: llm install [OPTIONS] [PACKAGES]... Install packages from PyPI into the same environment as LLM Options: - -U, --upgrade Upgrade packages to latest version - --help Show this message and exit. + -U, --upgrade Upgrade packages to latest version + -e, --editable DIRECTORY Install a project in editable mode from this path + --help Show this message and exit. ``` ### llm uninstall --help ``` diff --git a/llm/cli.py b/llm/cli.py index 0c6aea2..ea3e161 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -492,15 +492,23 @@ def templates_path(): @cli.command() -@click.argument("packages", nargs=-1, required=True) +@click.argument("packages", nargs=-1, required=False) @click.option( "-U", "--upgrade", is_flag=True, help="Upgrade packages to latest version" ) -def install(packages, upgrade): +@click.option( + "-e", + "--editable", + type=click.Path(readable=True, exists=True, dir_okay=True, file_okay=False), + help="Install a project in editable mode from this path", +) +def install(packages, upgrade, editable): """Install packages from PyPI into the same environment as LLM""" args = ["pip", "install"] if upgrade: args += ["--upgrade"] + if editable: + args += ["--editable", str(editable)] args += list(packages) sys.argv = args run_module("pip", run_name="__main__")