--no-cache-dir and --force-reinstall options, closes #146

This commit is contained in:
Simon Willison 2023-08-03 21:30:37 -07:00
parent c5adc59252
commit 609e8dead8
2 changed files with 18 additions and 1 deletions

View file

@ -292,6 +292,9 @@ Usage: llm install [OPTIONS] [PACKAGES]...
Options:
-U, --upgrade Upgrade packages to latest version
-e, --editable TEXT Install a project in editable mode from this path
--force-reinstall Reinstall all packages even if they are already up-to-
date
--no-cache-dir Disable the cache
--help Show this message and exit.
```
### llm uninstall --help

View file

@ -611,13 +611,27 @@ def templates_path():
"--editable",
help="Install a project in editable mode from this path",
)
def install(packages, upgrade, editable):
@click.option(
"--force-reinstall",
is_flag=True,
help="Reinstall all packages even if they are already up-to-date",
)
@click.option(
"--no-cache-dir",
is_flag=True,
help="Disable the cache",
)
def install(packages, upgrade, editable, force_reinstall, no_cache_dir):
"""Install packages from PyPI into the same environment as LLM"""
args = ["pip", "install"]
if upgrade:
args += ["--upgrade"]
if editable:
args += ["--editable", editable]
if force_reinstall:
args += ["--force-reinstall"]
if no_cache_dir:
args += ["--no-cache-dir"]
args += list(packages)
sys.argv = args
run_module("pip", run_name="__main__")