Skip to content

Commit

Permalink
setup: replace distutils.command.clean.clean by setuptool.Command
Browse files Browse the repository at this point in the history
Setuptools does not provide a clean command (see
pypa/setuptools#4034). So let the clean
commands inherit directly from `Command`.

Signed-off-by: Benjamin Drung <bdrung@posteo.de>
  • Loading branch information
bdrung committed Mar 1, 2024
1 parent 31857c5 commit 5222839
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# Setuptools replaces the `distutils` module in `sys.modules`.
# pylint: disable=wrong-import-order
import distutils.command.build # isort:skip, pylint: disable=deprecated-module
import distutils.command.clean # isort:skip, pylint: disable=deprecated-module

HOOKS = ["hooks/disable-units", "hooks/enable-units"]
MAN_PAGES = ["bdebstrap.1"]
Expand Down Expand Up @@ -61,16 +60,26 @@ def run(self) -> None:
super().run()


class CleanCommand(distutils.command.clean.clean):
class CleanCommand(Command):
"""Custom clean command (removing generated man pages)."""

description = "remove generated man pages"
user_options: list[tuple[str, str, str]] = []

def initialize_options(self) -> None:
"""Set default values for options."""

def finalize_options(self) -> None:
"""Post-process options."""

# pylint: disable-next=no-self-use
def run(self) -> None:
"""Clean build artefacts from doc command."""
logger = logging.getLogger(__name__)
for man_page in MAN_PAGES:
if os.path.exists(man_page):
logger.info("removing %s", man_page)
os.remove(man_page)
super().run()


if __name__ == "__main__":
Expand Down

0 comments on commit 5222839

Please sign in to comment.