kopia lustrzana https://github.com/simonw/datasette
datasette install --upgrade option, closes #945
rodzic
b21ed237ab
commit
69033c6ec4
|
@ -235,9 +235,16 @@ def package(
|
|||
|
||||
@cli.command()
|
||||
@click.argument("packages", nargs=-1, required=True)
|
||||
def install(packages):
|
||||
@click.option(
|
||||
"-U", "--upgrade", is_flag=True, help="Upgrade packages to latest version"
|
||||
)
|
||||
def install(packages, upgrade):
|
||||
"Install Python packages - e.g. Datasette plugins - into the same environment as Datasette"
|
||||
sys.argv = ["pip", "install"] + list(packages)
|
||||
args = ["pip", "install"]
|
||||
if upgrade:
|
||||
args += ["--upgrade"]
|
||||
args += list(packages)
|
||||
sys.argv = args
|
||||
run_module("pip", run_name="__main__")
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,15 @@ You can uninstall plugins with ``datasette uninstall``::
|
|||
|
||||
datasette uninstall datasette-vega
|
||||
|
||||
These ommands are thin wrappers around ``pip install`` and ``pip uninstall``, which ensure they run ``pip`` in the same virtual environment as Datasette itself.
|
||||
You can upgrade plugins with ``datasette install --upgrade`` or ``datasette install -U``::
|
||||
|
||||
datasette install -U datasette-vega
|
||||
|
||||
This command can also be used to upgrade Datasette itself to the latest released version::
|
||||
|
||||
datasette install -U datasette
|
||||
|
||||
These commands are thin wrappers around ``pip install`` and ``pip uninstall``, which ensure they run ``pip`` in the same virtual environment as Datasette itself.
|
||||
|
||||
One-off plugins using --plugins-dir
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -125,6 +125,15 @@ def test_install(run_module):
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("flag", ["-U", "--upgrade"])
|
||||
@mock.patch("datasette.cli.run_module")
|
||||
def test_install_upgrade(run_module, flag):
|
||||
runner = CliRunner()
|
||||
runner.invoke(cli, ["install", flag, "datasette"])
|
||||
run_module.assert_called_once_with("pip", run_name="__main__")
|
||||
assert sys.argv == ["pip", "install", "--upgrade", "datasette"]
|
||||
|
||||
|
||||
@mock.patch("datasette.cli.run_module")
|
||||
def test_uninstall(run_module):
|
||||
runner = CliRunner()
|
||||
|
|
Ładowanie…
Reference in New Issue