Skip to content

Commit c7ed71e

Browse files
committed
Use entry points for subcommand discovery
1 parent b39af4e commit c7ed71e

File tree

7 files changed

+47
-7
lines changed

7 files changed

+47
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ lsstcam/CALIB/calibRegistry.sqlite3
1919
lsstcam/CALIB/qe_curve/
2020
.vscode/
2121
.coverage*
22+
python/*.dist-info/

pyproject.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[project]
2+
name = "lsst-obs-lsst"
3+
4+
[project.entry-points.'butler.cli']
5+
obs_lsst = "lsst.obs.lsst.cli:get_cli_subcommands"
6+
17
[tool.ruff]
28
line-length = 110
39
target-version = "py311"
@@ -32,4 +38,3 @@ max-doc-length = 79
3238

3339
[tool.ruff.lint.pydocstyle]
3440
convention = "numpy"
35-

python/lsst/obs/lsst/cli/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ._get_cli_subcommands import get_cli_subcommands
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is part of obs_lsst.
2+
#
3+
# Developed for the LSST Data Management System.
4+
# This product includes software developed by the LSST Project
5+
# (http://www.lsst.org).
6+
# See the COPYRIGHT file at the top-level directory of this distribution
7+
# for details of code ownership.
8+
#
9+
# This program is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+
__all__ = ["get_cli_subcommands"]
23+
24+
import click
25+
26+
from . import cmd
27+
28+
29+
def get_cli_subcommands() -> list[click.Command]:
30+
"""Return the location of the CLI command plugin definitions.
31+
32+
Returns
33+
-------
34+
commands : `list` [ `click.Command` ]
35+
The command-line subcommands provided by this package.
36+
"""
37+
return [getattr(cmd, c) for c in cmd.__all__]

python/lsst/obs/lsst/cli/cmd/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2121

22+
__all__ = ["ingest_photodiode", "ingest_guider"]
23+
2224
from .commands import (
2325
ingest_photodiode,
2426
ingest_guider,

python/lsst/obs/lsst/cli/resources.yaml

-5
This file was deleted.

ups/obs_lsst.table

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ setupRequired(meas_algorithms)
1515

1616
envPrepend(PYTHONPATH, ${PRODUCT_DIR}/python)
1717
envPrepend(PATH, ${PRODUCT_DIR}/bin)
18-
envPrepend(DAF_BUTLER_PLUGINS, ${PRODUCT_DIR}/python/lsst/obs/lsst/cli/resources.yaml)

0 commit comments

Comments
 (0)