Skip to content

Commit

Permalink
Merge pull request #497 from lsst/tickets/DM-42226
Browse files Browse the repository at this point in the history
DM-42226: Use entry points for subcommand discovery
  • Loading branch information
timj authored Jan 2, 2025
2 parents 5c8c310 + c9a0413 commit 08a13b5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ tests/tmp*
version.py
tests/trivial_camera/qe_curves/ccd00/19700101T000000.ecsv
tests/trivial_camera/qe_curves/ccd00/19800101T000000.ecsv
python/*.dist-info/
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[project]
name = "lsst-obs-base"

[project.entry-points.'butler.cli']
obs_base = "lsst.obs.base.cli:get_cli_subcommands"

[tool.towncrier]
package = "lsst.obs.base"
package_dir = "python"
Expand Down
1 change: 1 addition & 0 deletions python/lsst/obs/base/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._get_cli_subcommands import get_cli_subcommands
37 changes: 37 additions & 0 deletions python/lsst/obs/base/cli/_get_cli_subcommands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is part of obs_base.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__all__ = ["get_cli_subcommands"]

import click

from . import cmd


def get_cli_subcommands() -> list[click.Command]:
"""Return the location of the CLI command plugin definitions.
Returns
-------
commands : `list` [ `click.Command` ]
The command-line subcommands provided by this package.
"""
return [getattr(cmd, c) for c in cmd.__all__]
7 changes: 0 additions & 7 deletions python/lsst/obs/base/cli/resources.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ import os

from lsst.sconsUtils import env, scripts
scripts.BasicSConscript.tests(pyList=[])

if "DAF_BUTLER_PLUGINS" in os.environ:
env["ENV"]["DAF_BUTLER_PLUGINS"] = os.environ["DAF_BUTLER_PLUGINS"]
1 change: 0 additions & 1 deletion ups/obs_base.table
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ setupOptional(log)

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

0 comments on commit 08a13b5

Please sign in to comment.