File: sdist.py

package info (click to toggle)
scikit-build 0.18.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,768 kB
  • sloc: python: 5,259; cpp: 284; makefile: 171; f90: 12; sh: 7
file content (39 lines) | stat: -rw-r--r-- 1,528 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
35
36
37
38
39
"""This module defines custom implementation of ``sdist`` setuptools command."""

from __future__ import annotations

from typing import Sequence

from setuptools.command.sdist import sdist as _sdist

from ..utils import distribution_hide_listing, logger
from . import CommandMixinProtocol, set_build_base_mixin


class sdist(set_build_base_mixin, _sdist):
    """Custom implementation of ``sdist`` setuptools command."""

    def make_release_tree(self: CommandMixinProtocol, base_dir: str, files: Sequence[str]) -> None:
        """Handle --hide-listing option."""
        with distribution_hide_listing(self.distribution):
            super().make_release_tree(base_dir, files)  # type: ignore[misc]
        logger.info("copied %d files", len(files))

    def make_archive(  # type: ignore[override]
        self,
        base_name: str,
        format: str,
        root_dir: str | None = None,
        base_dir: str | None = None,
        owner: str | None = None,
        group: str | None = None,
    ) -> str:
        """Handle --hide-listing option."""
        logger.info("creating '%s' %s archive and adding '%s' to it", base_name, format, base_dir)
        with distribution_hide_listing(self.distribution):
            return super().make_archive(base_name, format, root_dir, base_dir, owner, group)

    def run(self, *args: object, **kwargs: object) -> None:
        """Force :class:`.egg_info.egg_info` command to run."""
        self.run_command("generate_source_manifest")
        super().run(*args, **kwargs)