File: clean.py

package info (click to toggle)
scikit-build 0.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,792 kB
  • sloc: python: 5,258; cpp: 284; makefile: 171; f90: 12; sh: 7
file content (28 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""This module defines custom implementation of ``clean`` setuptools command."""

from __future__ import annotations

import os
from shutil import rmtree

import setuptools  # noqa: F401
from distutils.command.clean import clean as _clean

from ..constants import CMAKE_BUILD_DIR, CMAKE_INSTALL_DIR, SKBUILD_DIR
from ..utils import logger
from . import set_build_base_mixin


class clean(set_build_base_mixin, _clean):
    """Custom implementation of ``clean`` setuptools command."""

    def run(self) -> None:
        """After calling the super class implementation, this function removes
        the directories specific to scikit-build."""
        super().run()
        for dir_ in (CMAKE_INSTALL_DIR(), CMAKE_BUILD_DIR(), SKBUILD_DIR()):
            if os.path.exists(dir_):
                logger.info("removing '%s'", dir_)
            # This seems to be there but isn't typed in the stubs TODO
            if not self.dry_run and os.path.exists(dir_):  # type: ignore[attr-defined]
                rmtree(dir_)