mirror of
https://github.com/simonw/datasette.git
synced 2026-10-18 15:26:57 +02:00
Merge a25c656e83 into c435a80030
This commit is contained in:
commit
01d180ccc4
4 changed files with 69 additions and 1 deletions
|
|
@ -326,13 +326,34 @@ def package(
|
|||
"--editable",
|
||||
help="Install a project in editable mode from this path",
|
||||
)
|
||||
def install(packages, upgrade, requirement, editable):
|
||||
@click.option(
|
||||
"--pre", is_flag=True, help="Include pre-release and development versions"
|
||||
)
|
||||
@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, requirement, editable, pre, force_reinstall, no_cache_dir
|
||||
):
|
||||
"""Install plugins and packages from PyPI into the same environment as Datasette"""
|
||||
if not packages and not requirement and not editable:
|
||||
raise click.UsageError("Please specify at least one package to install")
|
||||
args = ["pip", "install"]
|
||||
if upgrade:
|
||||
args += ["--upgrade"]
|
||||
if pre:
|
||||
args += ["--pre"]
|
||||
if force_reinstall:
|
||||
args += ["--force-reinstall"]
|
||||
if no_cache_dir:
|
||||
args += ["--no-cache-dir"]
|
||||
if editable:
|
||||
args += ["--editable", editable]
|
||||
if requirement:
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ To collect telemetry, configure an OpenTelemetry SDK and exporter, then run Data
|
|||
Other features
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
- New ``--pre``, ``--force-reinstall``, and ``--no-cache-dir`` options for ``datasette install``. (:issue:`2483`)
|
||||
- New :ref:`DatasetteModal JavaScript API <javascript_plugins_modals>` for plugins to create dialogs with Datasette's shared styles, keyboard behavior and focus handling. Datasette's built-in dialogs use the same API. (:issue:`2790`, :pr:`2948`)
|
||||
|
||||
Bug fixes
|
||||
|
|
|
|||
|
|
@ -385,6 +385,10 @@ Would install the `datasette-cluster-map <https://datasette.io/plugins/datasette
|
|||
-U, --upgrade Upgrade packages to latest version
|
||||
-r, --requirement PATH Install from requirements file
|
||||
-e, --editable TEXT Install a project in editable mode from this path
|
||||
--pre Include pre-release and development versions
|
||||
--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.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -213,6 +213,48 @@ def test_install_requirements(run_module, tmpdir):
|
|||
assert sys.argv == ["pip", "install", "-r", str(path)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"flag,expected_arg",
|
||||
[
|
||||
("--pre", "--pre"),
|
||||
("--force-reinstall", "--force-reinstall"),
|
||||
("--no-cache-dir", "--no-cache-dir"),
|
||||
],
|
||||
)
|
||||
@mock.patch("datasette.cli.run_module")
|
||||
def test_install_flags(run_module, flag, expected_arg):
|
||||
runner = CliRunner()
|
||||
runner.invoke(cli, ["install", flag, "datasette-mock-plugin"])
|
||||
run_module.assert_called_once_with("pip", run_name="__main__")
|
||||
assert sys.argv == ["pip", "install", expected_arg, "datasette-mock-plugin"]
|
||||
|
||||
|
||||
@mock.patch("datasette.cli.run_module")
|
||||
def test_install_multiple_options(run_module):
|
||||
runner = CliRunner()
|
||||
runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"install",
|
||||
"--pre",
|
||||
"--force-reinstall",
|
||||
"--no-cache-dir",
|
||||
"-U",
|
||||
"datasette-mock-plugin",
|
||||
],
|
||||
)
|
||||
run_module.assert_called_once_with("pip", run_name="__main__")
|
||||
assert sys.argv == [
|
||||
"pip",
|
||||
"install",
|
||||
"--upgrade",
|
||||
"--pre",
|
||||
"--force-reinstall",
|
||||
"--no-cache-dir",
|
||||
"datasette-mock-plugin",
|
||||
]
|
||||
|
||||
|
||||
def test_install_error_if_no_packages():
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["install"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue