From 609e8dead8a6f9db1e42adde7a9f7cddb312a90e Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 3 Aug 2023 21:30:37 -0700 Subject: [PATCH] --no-cache-dir and --force-reinstall options, closes #146 --- docs/help.md | 3 +++ llm/cli.py | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/help.md b/docs/help.md index 6748400..851f70e 100644 --- a/docs/help.md +++ b/docs/help.md @@ -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 diff --git a/llm/cli.py b/llm/cli.py index 41a2339..7412547 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -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__")