Skip to content

Commit

Permalink
Merge pull request #453 from lsst/tickets/DM-47143
Browse files Browse the repository at this point in the history
DM-47143: Enable entry points for comand-line plugin discovery
  • Loading branch information
timj authored Oct 29, 2024
2 parents fb5b7f0 + daf71ce commit 01d4c0b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ jobs:
- name: Run tests
shell: bash -l {0}
env:
DAF_BUTLER_PLUGINS: ${{ github.workspace }}/python/lsst/pipe/base/cli/resources.yaml
run: |
pytest -r a -v -n 3 --cov=lsst.pipe.base --cov=tests --cov-report=xml --cov-report=term --cov-branch
butler register-instrument -h
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/DM-47143.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Plugin discovery is now automated through Python entry points when using ``pip``.
It is now an error if the ``DAF_BUTLER_PLUGINS`` environment variable is set for this package.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ dependencies = [

dynamic = ["version"]

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

[project.urls]
"Homepage" = "https://github.com/lsst/pipe_base"

Expand Down
1 change: 1 addition & 0 deletions python/lsst/pipe/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/pipe/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 pipe_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__]
2 changes: 1 addition & 1 deletion python/lsst/pipe/base/cli/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = ["register_instrument"]
__all__ = ["register_instrument", "transfer_from_graph"]

from .commands import register_instrument, transfer_from_graph

0 comments on commit 01d4c0b

Please sign in to comment.