llm install -e/--editable option

This commit is contained in:
Simon Willison 2023-07-05 17:58:19 -07:00
parent 78c93b9e23
commit f193468f76
2 changed files with 14 additions and 5 deletions

View file

@ -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
```

View file

@ -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__")