mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
install and uninstall commands, closes #483
This commit is contained in:
parent
0b315d3fa8
commit
85247038f7
3 changed files with 89 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ from click_default_group import DefaultGroup # type: ignore
|
|||
from datetime import datetime
|
||||
import hashlib
|
||||
import pathlib
|
||||
from runpy import run_module
|
||||
import sqlite_utils
|
||||
from sqlite_utils.db import AlterError, BadMultiValues, DescIndex, NoTable
|
||||
from sqlite_utils.utils import maximize_csv_field_size_limit
|
||||
|
|
@ -2657,6 +2658,30 @@ def _analyze(db, tables, columns, save):
|
|||
click.echo(details)
|
||||
|
||||
|
||||
@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 packages from PyPI into the same environment as sqlite-utils"""
|
||||
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 sqlite-utils environment"""
|
||||
sys.argv = ["pip", "uninstall"] + list(packages) + (["-y"] if yes else [])
|
||||
run_module("pip", run_name="__main__")
|
||||
|
||||
|
||||
def _generate_convert_help():
|
||||
help = textwrap.dedent(
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue