Added install/uninstall commands, #531

This commit is contained in:
Rhet Turnbull
2021-12-24 17:05:01 -08:00
parent 1cb8da96ce
commit 085f482820
15 changed files with 362 additions and 219 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.43.7"
__version__ = "0.43.8"

View File

@@ -20,6 +20,7 @@ import photoscript
import rich.traceback
import yaml
from rich import pretty
from runpy import run_module
import osxphotos
@@ -3602,6 +3603,30 @@ def run_post_command(
)
@cli.command()
@click.argument("packages", nargs=-1, required=True)
@click.option(
"-U", "--upgrade", is_flag=True, help="Upgrade packages to latest version"
)
def install(packages, upgrade):
"""Install Python packages into the same environment as osxphotos"""
args = ["pip", "install"]
if upgrade:
args += ["--upgrade"]
args += list(packages)
sys.argv = args
run_module("pip", run_name="__main__")
@cli.command()
@click.argument("packages", nargs=-1, required=True)
@click.option("-y", "--yes", is_flag=True, help="Don't ask for confirmation")
def uninstall(packages, yes):
"""Uninstall Python packages from the osxphotos environment"""
sys.argv = ["pip", "uninstall"] + list(packages) + (["-y"] if yes else [])
run_module("pip", run_name="__main__")
@cli.command(hidden=True)
@DB_OPTION
@DB_ARGUMENT