From be8f1a559d8209710a08ca48d93b7f513fa1c42f Mon Sep 17 00:00:00 2001 From: David Douard <david.douard@sdfa3.org> Date: Wed, 23 Sep 2020 17:52:14 +0200 Subject: [PATCH] Adapt cli declaration entrypoint to swh.core 0.3 The addition of '-p no:pytest_swh_core' in pytest.ini is needed to prevent pytest from loading the pytest_swh_core plugin which we do not need here and which would require some more dependencies (e.g. requests). --- pytest.ini | 2 +- requirements-cli.txt | 2 +- setup.py | 4 ++-- swh/model/cli.py | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pytest.ini b/pytest.ini index 7a1413f2..9fa2d75a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = --doctest-modules +addopts = --doctest-modules -p no:pytest_swh_core norecursedirs = docs .* markers = fs: tests that involve filesystem ios diff --git a/requirements-cli.txt b/requirements-cli.txt index 7365d1f9..8564d009 100644 --- a/requirements-cli.txt +++ b/requirements-cli.txt @@ -1,3 +1,3 @@ -swh.core +swh.core >= 0.3 Click dulwich diff --git a/setup.py b/setup.py index f42058ca..8f9d32fd 100755 --- a/setup.py +++ b/setup.py @@ -54,14 +54,14 @@ setup( ), extras_require={ "cli": parse_requirements("cli"), - "testing": parse_requirements("test"), + "testing": parse_requirements("test") + parse_requirements("cli"), }, include_package_data=True, entry_points=""" [console_scripts] swh-identify=swh.model.cli:identify [swh.cli.subcommands] - identify=swh.model.cli:identify + identify=swh.model.cli """, classifiers=[ "Programming Language :: Python :: 3", diff --git a/swh/model/cli.py b/swh/model/cli.py index 68a36805..4c8b7c17 100644 --- a/swh/model/cli.py +++ b/swh/model/cli.py @@ -9,6 +9,8 @@ import sys # WARNING: do not import unnecessary things here to keep cli startup time under # control import click +from swh.core.cli import swh as swh_cli_group + CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) @@ -138,7 +140,7 @@ def identify_object(obj_type, follow_symlinks, obj): return (obj, swhid) -@click.command(context_settings=CONTEXT_SETTINGS) +@swh_cli_group.command(context_settings=CONTEXT_SETTINGS) @click.option( "--dereference/--no-dereference", "follow_symlinks", -- GitLab