File: __init__.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 (34 lines) | stat: -rw-r--r-- 1,122 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
29
30
31
32
33
34
"""Collection of objects allowing to customize behavior of standard
distutils and setuptools commands.
"""

from __future__ import annotations

from .._compat.typing import Protocol
from ..constants import SETUPTOOLS_INSTALL_DIR
from ..utils import Distribution


class CommandMixinProtocol(Protocol):
    """Protocol for commands that use CMake."""

    build_base: str
    distribution: Distribution
    outfiles: list[str]
    install_lib: str | None
    install_platlib: str

    # pylint: disable-next=missing-function-docstring
    def finalize_options(self, *args: object, **kwargs: object) -> None: ...


class set_build_base_mixin:
    """Mixin allowing to override distutils and setuptools commands."""

    def finalize_options(self: CommandMixinProtocol, *args: object, **kwargs: object) -> None:
        """Override built-in function and set a new `build_base`."""
        build_base = getattr(self, "build_base", "EMPTY")
        if not build_base or build_base == "build":
            self.build_base = SETUPTOOLS_INSTALL_DIR()

        super().finalize_options(*args, **kwargs)  # type: ignore[safe-super]