Skip to content

Commit

Permalink
Support publishing plugins that expose rules. (pantsbuild#8693)
Browse files Browse the repository at this point in the history
The extension loading code in `pants.init.extension_loader` already
supports the `pantsbuild.plugin:rules` entrypoint so this just needed
to be plumbed.
  • Loading branch information
jsirois authored Nov 24, 2019
1 parent 1d7e589 commit 9f8cb1e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(self,
build_file_aliases=False,
global_subsystems=False,
register_goals=False,
rules=False,
**kwargs):
"""
:param str distribution_name: The name of the plugin package; must start with
Expand All @@ -166,6 +167,8 @@ def __init__(self,
registers the 'global_subsystems' 'pantsbuild.plugin' entrypoint.
:param bool register_goals: If `True`, register.py:register_goals must be defined and
registers the 'register_goals' 'pantsbuild.plugin' entrypoint.
:param bool rules: If `True`, register.py:rules must be defined and registers the 'rules'
'pantsbuild.plugin' entrypoint.
"""
if not distribution_name.startswith('pantsbuild.pants.'):
raise ValueError(
Expand All @@ -185,7 +188,7 @@ def __init__(self,

super().__init__(address, payload, provides=setup_py, **kwargs)

if build_file_aliases or register_goals or global_subsystems:
if build_file_aliases or register_goals or global_subsystems or rules:
module = os.path.relpath(address.spec_path, self.target_base).replace(os.sep, '.')
entrypoints = []
if build_file_aliases:
Expand All @@ -194,6 +197,8 @@ def __init__(self,
entrypoints.append(f'register_goals = {module}.register:register_goals')
if global_subsystems:
entrypoints.append(f'global_subsystems = {module}.register:global_subsystems')
if rules:
entrypoints.append(f'rules = {module}.register:rules')
entry_points = {'pantsbuild.plugin': entrypoints}

setup_py.setup_py_keywords['entry_points'] = entry_points
Expand Down

0 comments on commit 9f8cb1e

Please sign in to comment.