Skip to content

Commit

Permalink
Allow custom-command to "install" itself
Browse files Browse the repository at this point in the history
The comment in pypa/setuptools#2591 (comment)
reports that users wanting to use the custom-command plugin need to
explicitly add it using `setup.py`.

This commit tried to demonstrate how that can be done without requiring
the user to change their `setup.py`.

The "installation" of the new sub-command is done via the
`finalize_distribution_options` hook.
  • Loading branch information
abravalheri committed Jun 24, 2022
1 parent bf2a563 commit e0b4ceb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ def finalize_options(self):

def run(self):
log.info("brrrrrrrrr")


def install(dist):
# This could be protected by a opt-in condition...
build = dist.get_command_obj("build")
build.sub_commands = [*build.sub_commands, ("custom-build", None)]
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ packages = find_namespace:
[options.entry_points]
distutils.commands =
custom-build = custom.build:Command
setuptools.finalize_distribution_options =
custom-build = custom.build:install

0 comments on commit e0b4ceb

Please sign in to comment.