diff --git a/_distutils_hack/__init__.py b/_distutils_hack/__init__.py index 30ac3a7403..6ee497b38f 100644 --- a/_distutils_hack/__init__.py +++ b/_distutils_hack/__init__.py @@ -3,8 +3,7 @@ import sys report_url = ( - "https://github.com/pypa/setuptools/issues/new?" - "template=distutils-deprecation.yml" + "https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml" ) diff --git a/mypy.ini b/mypy.ini index cadfa6be59..83a82c6826 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,7 +5,7 @@ strict = False # Early opt-in even when strict = False -# warn_unused_ignores = True # Disabled until we have distutils stubs for Python 3.12+ +warn_unused_ignores = True warn_redundant_casts = True enable_error_code = ignore-without-code @@ -18,6 +18,9 @@ disable_error_code = ## local +# Use our custom stubs for distutils +mypy_path = $MYPY_CONFIG_FILE_DIR/typings + # CI should test for all versions, local development gets hints for oldest supported # But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually. # python_version = 3.8 @@ -48,17 +51,10 @@ disable_error_code = [mypy-pkg_resources.tests.*] disable_error_code = import-not-found -# - distutils doesn't exist on Python 3.12, unfortunately, this means typing -# will be missing for subclasses of distutils on Python 3.12 until either: -# - support for `SETUPTOOLS_USE_DISTUTILS=stdlib` is dropped (#3625) -# for setuptools to import `_distutils` directly -# - or non-stdlib distutils typings are exposed -[mypy-distutils.*] -ignore_missing_imports = True - # - wheel: does not intend on exposing a programmatic API https://github.com/pypa/wheel/pull/610#issuecomment-2081687671 [mypy-wheel.*] ignore_missing_imports = True + # - The following are not marked as py.typed: # - jaraco: Since mypy 1.12, the root name of the untyped namespace package gets called-out too # - jaraco.develop: https://github.com/jaraco/jaraco.develop/issues/22 diff --git a/pyproject.toml b/pyproject.toml index 1a4906fb0c..4b2d99e6ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -133,6 +133,8 @@ type = [ # local + # Referenced in distutils-stubs + "types-docutils", # pin mypy version so a new version doesn't suddenly cause the CI to fail, # until types-setuptools is removed from typeshed. # For help with static-typing issues, or mypy update, ping @Avasam @@ -203,6 +205,8 @@ include-package-data = true include = [ "setuptools*", "pkg_resources*", + # TODO: Include distutils stubs with package once we're confident in them + # "typings/distutils-stubs", "_distutils_hack*", ] exclude = [ diff --git a/pyrightconfig.json b/pyrightconfig.json index 27a329e169..4d906d5553 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -12,6 +12,8 @@ ], // Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually. // "pythonVersion": "3.8", + // Allow using distutils-stubs on Python 3.12+ + "reportMissingModuleSource": false, // For now we don't mind if mypy's `type: ignore` comments accidentally suppresses pyright issues "enableTypeIgnoreComments": true, "typeCheckingMode": "basic", diff --git a/ruff.toml b/ruff.toml index e154cdf70d..9d00e7685e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -34,6 +34,9 @@ ignore = [ # Only enforcing return type annotations for public functions "ANN202", # missing-return-type-private-function "ANN204", # missing-return-type-special-method + # Typeshed doesn't want complex or non-literal defaults for maintenance and testing reasons. + # This doesn't affect us, let's have more complete stubs. + "PYI011", # typed-argument-default-in-stub # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", diff --git a/setuptools/__init__.py b/setuptools/__init__.py index eba86c4f9c..7ccf80205e 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -1,9 +1,4 @@ """Extensions to the 'distutils' for large or complex distributions""" -# mypy: disable_error_code=override -# Command.reinitialize_command has an extra **kw param that distutils doesn't have -# Can't disable on the exact line because distutils doesn't exists on Python 3.12 -# and mypy isn't aware of distutils_hack, causing distutils.core.Command to be Any, -# and a [unused-ignore] to be raised on 3.12+ from __future__ import annotations @@ -213,7 +208,7 @@ def ensure_string_list(self, option: str): "'%s' must be a list of strings (got %r)" % (option, val) ) - @overload + @overload # type: ignore[override] # Has an extra **kw param that distutils doesn't have def reinitialize_command( self, command: str, reinit_subcommands: bool = False, **kw ) -> _Command: ... diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 628a20b40b..75bfe3bbd2 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -143,7 +143,7 @@ def find_data_files(self, package, src_dir): ) return self.exclude_data_files(package, src_dir, files) - def get_outputs(self, include_bytecode: bool = True) -> list[str]: # type: ignore[override] # Using a real boolean instead of 0|1 + def get_outputs(self, include_bytecode: bool = True) -> list[str]: """See :class:`setuptools.commands.build.SubCommand`""" if self.editable_mode: return list(self.get_output_mapping().keys()) diff --git a/setuptools/command/install_lib.py b/setuptools/command/install_lib.py index 53b68f6363..88ffdbeec9 100644 --- a/setuptools/command/install_lib.py +++ b/setuptools/command/install_lib.py @@ -95,10 +95,9 @@ def copy_tree( self, infile: StrPath, outfile: str, - # override: Using actual booleans - preserve_mode: bool = True, # type: ignore[override] - preserve_times: bool = True, # type: ignore[override] - preserve_symlinks: bool = False, # type: ignore[override] + preserve_mode: bool = True, + preserve_times: bool = True, + preserve_symlinks: bool = False, level: object = 1, ) -> list[str]: assert preserve_mode and preserve_times and not preserve_symlinks diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index 35fe4f9aa9..751d53c36c 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -24,10 +24,8 @@ Generic, Iterable, Iterator, - List, Tuple, TypeVar, - cast, ) from packaging.markers import default_environment as marker_env @@ -112,8 +110,7 @@ def _apply( filenames = [*other_files, filepath] try: - # TODO: Temporary cast until mypy 1.12 is released with upstream fixes from typeshed - _Distribution.parse_config_files(dist, filenames=cast(List[str], filenames)) + _Distribution.parse_config_files(dist, filenames=filenames) handlers = parse_configuration( dist, dist.command_options, ignore_option_errors=ignore_option_errors ) diff --git a/setuptools/errors.py b/setuptools/errors.py index 990ecbf4e2..61b0a55c72 100644 --- a/setuptools/errors.py +++ b/setuptools/errors.py @@ -30,15 +30,15 @@ BaseError = _distutils_errors.DistutilsError -class InvalidConfigError(OptionError): # type: ignore[valid-type, misc] # distutils imports are `Any` on python 3.12+ +class InvalidConfigError(OptionError): """Error used for invalid configurations.""" -class RemovedConfigError(OptionError): # type: ignore[valid-type, misc] # distutils imports are `Any` on python 3.12+ +class RemovedConfigError(OptionError): """Error used for configurations that were deprecated and removed.""" -class RemovedCommandError(BaseError, RuntimeError): # type: ignore[valid-type, misc] # distutils imports are `Any` on python 3.12+ +class RemovedCommandError(BaseError, RuntimeError): """Error used for commands that have been removed in setuptools. Since ``setuptools`` is built on ``distutils``, simply removing a command @@ -48,7 +48,7 @@ class RemovedCommandError(BaseError, RuntimeError): # type: ignore[valid-type, """ -class PackageDiscoveryError(BaseError, RuntimeError): # type: ignore[valid-type, misc] # distutils imports are `Any` on python 3.12+ +class PackageDiscoveryError(BaseError, RuntimeError): """Impossible to perform automatic discovery of packages and/or modules. The current project layout or given discovery options can lead to problems when diff --git a/typings/distutils-stubs/__init__.pyi b/typings/distutils-stubs/__init__.pyi new file mode 100644 index 0000000000..e69de29bb2 diff --git a/typings/distutils-stubs/_modified.pyi b/typings/distutils-stubs/_modified.pyi new file mode 100644 index 0000000000..84444dc04a --- /dev/null +++ b/typings/distutils-stubs/_modified.pyi @@ -0,0 +1,25 @@ +from collections.abc import Callable, Iterable +from typing import Literal, TypeVar + +from _typeshed import StrOrBytesPath + +_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) +_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) + +def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool: ... +def newer_pairwise( + sources: Iterable[_SourcesT], + targets: Iterable[_TargetsT], + newer: Callable[[_SourcesT, _TargetsT], bool] = newer, +) -> tuple[list[_SourcesT], list[_TargetsT]]: ... +def newer_group( + sources: Iterable[StrOrBytesPath], + target: StrOrBytesPath, + missing: Literal["error", "ignore", "newer"] = "error", +) -> bool: ... +def newer_pairwise_group( + sources: Iterable[_SourcesT], + targets: Iterable[_TargetsT], + *, + newer: Callable[[_SourcesT, _TargetsT], bool] = newer, +) -> tuple[list[_SourcesT], list[_TargetsT]]: ... diff --git a/typings/distutils-stubs/archive_util.pyi b/typings/distutils-stubs/archive_util.pyi new file mode 100644 index 0000000000..ad37d64ce8 --- /dev/null +++ b/typings/distutils-stubs/archive_util.pyi @@ -0,0 +1,38 @@ +from typing import Literal, overload + +from _typeshed import StrOrBytesPath, StrPath + +@overload +def make_archive( + base_name: str, + format: str, + root_dir: StrOrBytesPath | None = None, + base_dir: str | None = None, + verbose: bool = False, + dry_run: bool = False, + owner: str | None = None, + group: str | None = None, +) -> str: ... +@overload +def make_archive( + base_name: StrPath, + format: str, + root_dir: StrOrBytesPath, + base_dir: str | None = None, + verbose: bool = False, + dry_run: bool = False, + owner: str | None = None, + group: str | None = None, +) -> str: ... +def make_tarball( + base_name: str, + base_dir: StrPath, + compress: Literal["gzip", "bzip2", "xz"] | None = "gzip", + verbose: bool = False, + dry_run: bool = False, + owner: str | None = None, + group: str | None = None, +) -> str: ... +def make_zipfile( + base_name: str, base_dir: str, verbose: bool = False, dry_run: bool = False +) -> str: ... diff --git a/typings/distutils-stubs/bcppcompiler.pyi b/typings/distutils-stubs/bcppcompiler.pyi new file mode 100644 index 0000000000..036983117c --- /dev/null +++ b/typings/distutils-stubs/bcppcompiler.pyi @@ -0,0 +1,3 @@ +from .ccompiler import CCompiler + +class BCPPCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/ccompiler.pyi b/typings/distutils-stubs/ccompiler.pyi new file mode 100644 index 0000000000..bd5a79bc68 --- /dev/null +++ b/typings/distutils-stubs/ccompiler.pyi @@ -0,0 +1,215 @@ +from collections.abc import Callable, Iterable +from typing import ClassVar, Literal, TypeVar, overload + +from _typeshed import BytesPath, StrPath, Unused +from typing_extensions import TypeAlias, TypeVarTuple, Unpack + +_Macro: TypeAlias = tuple[str] | tuple[str, str | None] +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) +_Ts = TypeVarTuple("_Ts") + +def gen_lib_options( + compiler: CCompiler, + library_dirs: list[str], + runtime_library_dirs: list[str], + libraries: list[str], +) -> list[str]: ... +def gen_preprocess_options( + macros: list[_Macro], include_dirs: list[str] +) -> list[str]: ... +def get_default_compiler( + osname: str | None = None, platform: str | None = None +) -> str: ... +def new_compiler( + plat: str | None = None, + compiler: str | None = None, + verbose: bool = False, + dry_run: bool = False, + force: bool = False, +) -> CCompiler: ... +def show_compilers() -> None: ... + +class CCompiler: + src_extensions: ClassVar[list[str] | None] + obj_extension: ClassVar[str | None] + static_lib_extension: ClassVar[str | None] + shared_lib_extension: ClassVar[str | None] + static_lib_format: ClassVar[str | None] + shared_lib_format: ClassVar[str | None] + exe_extension: ClassVar[str | None] + language_map: ClassVar[dict[str, str]] + language_order: ClassVar[list[str]] + dry_run: bool + force: bool + verbose: bool + output_dir: str | None + macros: list[_Macro] + include_dirs: list[str] + libraries: list[str] + library_dirs: list[str] + runtime_library_dirs: list[str] + objects: list[str] + def __init__( + self, verbose: bool = False, dry_run: bool = False, force: bool = False + ) -> None: ... + def add_include_dir(self, dir: str) -> None: ... + def set_include_dirs(self, dirs: list[str]) -> None: ... + def add_library(self, libname: str) -> None: ... + def set_libraries(self, libnames: list[str]) -> None: ... + def add_library_dir(self, dir: str) -> None: ... + def set_library_dirs(self, dirs: list[str]) -> None: ... + def add_runtime_library_dir(self, dir: str) -> None: ... + def set_runtime_library_dirs(self, dirs: list[str]) -> None: ... + def define_macro(self, name: str, value: str | None = None) -> None: ... + def undefine_macro(self, name: str) -> None: ... + def add_link_object(self, object: str) -> None: ... + def set_link_objects(self, objects: list[str]) -> None: ... + def detect_language(self, sources: str | list[str]) -> str | None: ... + def find_library_file( + self, dirs: list[str], lib: str, debug: bool = False + ) -> str | None: ... + def has_function( + self, + funcname: str, + includes: list[str] | None = None, + include_dirs: list[str] | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + ) -> bool: ... + def library_dir_option(self, dir: str) -> str: ... + def library_option(self, lib: str) -> str: ... + def runtime_library_dir_option(self, dir: str) -> str: ... + def set_executables(self, **args: str) -> None: ... + def compile( + self, + sources: list[str], + output_dir: str | None = None, + macros: list[_Macro] | None = None, + include_dirs: list[str] | None = None, + debug: bool = False, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + depends: list[str] | None = None, + ) -> list[str]: ... + def create_static_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = None, + debug: bool = False, + target_lang: str | None = None, + ) -> None: ... + def link( + self, + target_desc: str, + objects: list[str], + output_filename: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool = False, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_executable( + self, + objects: list[str], + output_progname: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + debug: bool = False, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_shared_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool = False, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_shared_object( + self, + objects: list[str], + output_filename: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool = False, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def preprocess( + self, + source: str, + output_file: str | None = None, + macros: list[_Macro] | None = None, + include_dirs: list[str] | None = None, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + ) -> None: ... + @overload + def executable_filename( + self, basename: str, strip_dir: Literal[False] = False, output_dir: StrPath = "" + ) -> str: ... + @overload + def executable_filename( + self, basename: StrPath, strip_dir: Literal[True], output_dir: StrPath = "" + ) -> str: ... + def library_filename( + self, + libname: str, + lib_type: str = "static", + strip_dir: bool = False, + output_dir: StrPath = "", + ) -> str: ... + def object_filenames( + self, + source_filenames: Iterable[StrPath], + strip_dir: bool = False, + output_dir: StrPath | None = '', + ) -> list[str]: ... + @overload + def shared_object_filename( + self, basename: str, strip_dir: Literal[False] = False, output_dir: StrPath = "" + ) -> str: ... + @overload + def shared_object_filename( + self, basename: StrPath, strip_dir: Literal[True], output_dir: StrPath = "" + ) -> str: ... + def execute( + self, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + level: int = 1, + ) -> None: ... + def spawn(self, cmd: list[str]) -> None: ... + def mkpath(self, name: str, mode: int = 0o777) -> None: ... + @overload + def move_file(self, src: StrPath, dst: _StrPathT) -> _StrPathT | str: ... + @overload + def move_file(self, src: BytesPath, dst: _BytesPathT) -> _BytesPathT | bytes: ... + def announce(self, msg: str, level: int = 1) -> None: ... + def warn(self, msg: str) -> None: ... + def debug_print(self, msg: str) -> None: ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi new file mode 100644 index 0000000000..15f59e6d46 --- /dev/null +++ b/typings/distutils-stubs/cmd.pyi @@ -0,0 +1,309 @@ +from abc import abstractmethod +from collections.abc import Callable, Iterable +from typing import Any, ClassVar, Literal, TypeVar, overload + +from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused +from typing_extensions import TypeVarTuple, Unpack + +from .command.bdist import bdist +from .command.bdist_dumb import bdist_dumb +from .command.bdist_rpm import bdist_rpm +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.build_scripts import build_scripts +from .command.check import check +from .command.clean import clean +from .command.config import config +from .command.install import install +from .command.install_data import install_data +from .command.install_egg_info import install_egg_info +from .command.install_headers import install_headers +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.sdist import sdist +from .command.upload import upload +from .dist import Distribution + +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) +_CommandT = TypeVar("_CommandT", bound=Command) +_Ts = TypeVarTuple("_Ts") + +class Command: + dry_run: bool # Exposed from __getattr_. Same as Distribution.dry_run + distribution: Distribution + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] + def __init__(self, dist: Distribution) -> None: ... + def ensure_finalized(self) -> None: ... + @abstractmethod + def initialize_options(self) -> None: ... + @abstractmethod + def finalize_options(self) -> None: ... + @abstractmethod + def run(self) -> None: ... + def announce(self, msg: str, level: int = 10) -> None: ... + def debug_print(self, msg: str) -> None: ... + def ensure_string(self, option: str, default: str | None = None) -> None: ... + def ensure_string_list(self, option: str) -> None: ... + def ensure_filename(self, option: str) -> None: ... + def ensure_dirname(self, option: str) -> None: ... + def get_command_name(self) -> str: ... + def set_undefined_options( + self, src_cmd: str, *option_pairs: tuple[str, str] + ) -> None: ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_finalized_command( + self, command: Literal["bdist"], create: bool = True + ) -> bdist: ... + @overload + def get_finalized_command( + self, command: Literal["bdist_dumb"], create: bool = True + ) -> bdist_dumb: ... + @overload + def get_finalized_command( + self, command: Literal["bdist_rpm"], create: bool = True + ) -> bdist_rpm: ... + @overload + def get_finalized_command( + self, command: Literal["build"], create: bool = True + ) -> build: ... + @overload + def get_finalized_command( + self, command: Literal["build_clib"], create: bool = True + ) -> build_clib: ... + @overload + def get_finalized_command( + self, command: Literal["build_ext"], create: bool = True + ) -> build_ext: ... + @overload + def get_finalized_command( + self, command: Literal["build_py"], create: bool = True + ) -> build_py: ... + @overload + def get_finalized_command( + self, command: Literal["build_scripts"], create: bool = True + ) -> build_scripts: ... + @overload + def get_finalized_command( + self, command: Literal["check"], create: bool = True + ) -> check: ... + @overload + def get_finalized_command( + self, command: Literal["clean"], create: bool = True + ) -> clean: ... + @overload + def get_finalized_command( + self, command: Literal["config"], create: bool = True + ) -> config: ... + @overload + def get_finalized_command( + self, command: Literal["install"], create: bool = True + ) -> install: ... + @overload + def get_finalized_command( + self, command: Literal["install_data"], create: bool = True + ) -> install_data: ... + @overload + def get_finalized_command( + self, command: Literal["install_egg_info"], create: bool = True + ) -> install_egg_info: ... + @overload + def get_finalized_command( + self, command: Literal["install_headers"], create: bool = True + ) -> install_headers: ... + @overload + def get_finalized_command( + self, command: Literal["install_lib"], create: bool = True + ) -> install_lib: ... + @overload + def get_finalized_command( + self, command: Literal["install_scripts"], create: bool = True + ) -> install_scripts: ... + @overload + def get_finalized_command( + self, command: Literal["register"], create: bool = True + ) -> register: ... + @overload + def get_finalized_command( + self, command: Literal["sdist"], create: bool = True + ) -> sdist: ... + @overload + def get_finalized_command( + self, command: Literal["upload"], create: bool = True + ) -> upload: ... + @overload + def get_finalized_command(self, command: str, create: bool = True) -> Command: ... + @overload + def reinitialize_command( + self, command: Literal["bdist"], reinit_subcommands: bool = False + ) -> bdist: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False + ) -> bdist_dumb: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False + ) -> bdist_rpm: ... + @overload + def reinitialize_command( + self, command: Literal["build"], reinit_subcommands: bool = False + ) -> build: ... + @overload + def reinitialize_command( + self, command: Literal["build_clib"], reinit_subcommands: bool = False + ) -> build_clib: ... + @overload + def reinitialize_command( + self, command: Literal["build_ext"], reinit_subcommands: bool = False + ) -> build_ext: ... + @overload + def reinitialize_command( + self, command: Literal["build_py"], reinit_subcommands: bool = False + ) -> build_py: ... + @overload + def reinitialize_command( + self, command: Literal["build_scripts"], reinit_subcommands: bool = False + ) -> build_scripts: ... + @overload + def reinitialize_command( + self, command: Literal["check"], reinit_subcommands: bool = False + ) -> check: ... + @overload + def reinitialize_command( + self, command: Literal["clean"], reinit_subcommands: bool = False + ) -> clean: ... + @overload + def reinitialize_command( + self, command: Literal["config"], reinit_subcommands: bool = False + ) -> config: ... + @overload + def reinitialize_command( + self, command: Literal["install"], reinit_subcommands: bool = False + ) -> install: ... + @overload + def reinitialize_command( + self, command: Literal["install_data"], reinit_subcommands: bool = False + ) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False + ) -> install_egg_info: ... + @overload + def reinitialize_command( + self, command: Literal["install_headers"], reinit_subcommands: bool = False + ) -> install_headers: ... + @overload + def reinitialize_command( + self, command: Literal["install_lib"], reinit_subcommands: bool = False + ) -> install_lib: ... + @overload + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool = False + ) -> install_scripts: ... + @overload + def reinitialize_command( + self, command: Literal["register"], reinit_subcommands: bool = False + ) -> register: ... + @overload + def reinitialize_command( + self, command: Literal["sdist"], reinit_subcommands: bool = False + ) -> sdist: ... + @overload + def reinitialize_command( + self, command: Literal["upload"], reinit_subcommands: bool = False + ) -> upload: ... + @overload + def reinitialize_command( + self, command: str, reinit_subcommands: bool = False + ) -> Command: ... + @overload + def reinitialize_command( + self, command: _CommandT, reinit_subcommands: bool = False + ) -> _CommandT: ... + def run_command(self, command: str) -> None: ... + def get_sub_commands(self) -> list[str]: ... + def warn(self, msg: str) -> None: ... + def execute( + self, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + level: int = 1, + ) -> None: ... + def mkpath(self, name: str, mode: int = 0o777) -> None: ... + @overload + def copy_file( + self, + infile: StrPath, + outfile: _StrPathT, + preserve_mode: bool = True, + preserve_times: bool = True, + link: str | None = None, + level: Unused = 1, + ) -> tuple[_StrPathT | str, bool]: ... + @overload + def copy_file( + self, + infile: BytesPath, + outfile: _BytesPathT, + preserve_mode: bool = True, + preserve_times: bool = True, + link: str | None = None, + level: Unused = 1, + ) -> tuple[_BytesPathT | bytes, bool]: ... + def copy_tree( + self, + infile: StrPath, + outfile: str, + preserve_mode: bool = True, + preserve_times: bool = True, + preserve_symlinks: bool = False, + level: Unused = 1, + ) -> list[str]: ... + @overload + def move_file( + self, src: StrPath, dst: _StrPathT, level: Unused = 1 + ) -> _StrPathT | str: ... + @overload + def move_file( + self, src: BytesPath, dst: _BytesPathT, level: Unused = 1 + ) -> _BytesPathT | bytes: ... + def spawn( + self, cmd: Iterable[str], search_path: bool = True, level: Unused = 1 + ) -> None: ... + @overload + def make_archive( + self, + base_name: str, + format: str, + root_dir: StrOrBytesPath | None = None, + base_dir: str | None = None, + owner: str | None = None, + group: str | None = None, + ) -> str: ... + @overload + def make_archive( + self, + base_name: StrPath, + format: str, + root_dir: StrOrBytesPath, + base_dir: str | None = None, + owner: str | None = None, + group: str | None = None, + ) -> str: ... + def make_file( + self, + infiles: str | list[str] | tuple[str, ...], + outfile: StrOrBytesPath, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + exec_msg: str | None = None, + skip_msg: str | None = None, + level: Unused = 1, + ) -> None: ... diff --git a/typings/distutils-stubs/command/__init__.pyi b/typings/distutils-stubs/command/__init__.pyi new file mode 100644 index 0000000000..856c5eb8b4 --- /dev/null +++ b/typings/distutils-stubs/command/__init__.pyi @@ -0,0 +1,41 @@ +from . import ( + bdist, + bdist_dumb, + bdist_rpm, + build, + build_clib, + build_ext, + build_py, + build_scripts, + check, + clean, + install, + install_data, + install_headers, + install_lib, + install_scripts, + register, + sdist, + upload, +) + +__all__ = [ + "build", + "build_py", + "build_ext", + "build_clib", + "build_scripts", + "clean", + "install", + "install_lib", + "install_headers", + "install_scripts", + "install_data", + "sdist", + "register", + "bdist", + "bdist_dumb", + "bdist_rpm", + "check", + "upload", +] diff --git a/typings/distutils-stubs/command/bdist.pyi b/typings/distutils-stubs/command/bdist.pyi new file mode 100644 index 0000000000..43e6ece30e --- /dev/null +++ b/typings/distutils-stubs/command/bdist.pyi @@ -0,0 +1,27 @@ +from collections.abc import Callable +from typing import ClassVar + +from _typeshed import Unused +from typing_extensions import deprecated + +from ..cmd import Command + +def show_formats() -> None: ... + +class ListCompat(dict[str, tuple[str, str]]): + @deprecated("format_commands is now a dict. append is deprecated") + def append(self, item: Unused) -> None: ... + +class bdist(Command): + description: ClassVar[str] + user_options: ClassVar[list[tuple[str, str | None, str | None]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + no_format_option: ClassVar[tuple[str, ...]] + default_format: ClassVar[dict[str, str]] + format_commands: ClassVar[ListCompat] + format_command = format_commands + + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_dumb.pyi b/typings/distutils-stubs/command/bdist_dumb.pyi new file mode 100644 index 0000000000..d7943b76d7 --- /dev/null +++ b/typings/distutils-stubs/command/bdist_dumb.pyi @@ -0,0 +1,23 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class bdist_dumb(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + default_format: ClassVar[dict[str, str]] + bdist_dir: Incomplete + plat_name: Incomplete + format: Incomplete + keep_temp: int + dist_dir: Incomplete + skip_build: Incomplete + relative: int + owner: Incomplete + group: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_packager.pyi b/typings/distutils-stubs/command/bdist_packager.pyi new file mode 100644 index 0000000000..e69de29bb2 diff --git a/typings/distutils-stubs/command/bdist_rpm.pyi b/typings/distutils-stubs/command/bdist_rpm.pyi new file mode 100644 index 0000000000..eca2780b55 --- /dev/null +++ b/typings/distutils-stubs/command/bdist_rpm.pyi @@ -0,0 +1,54 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class bdist_rpm(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + bdist_base: Incomplete + rpm_base: Incomplete + dist_dir: Incomplete + python: Incomplete + fix_python: Incomplete + spec_only: Incomplete + binary_only: Incomplete + source_only: Incomplete + use_bzip2: Incomplete + distribution_name: Incomplete + group: Incomplete + release: Incomplete + serial: Incomplete + vendor: Incomplete + packager: Incomplete + doc_files: Incomplete + changelog: Incomplete + icon: Incomplete + prep_script: Incomplete + build_script: Incomplete + install_script: Incomplete + clean_script: Incomplete + verify_script: Incomplete + pre_install: Incomplete + post_install: Incomplete + pre_uninstall: Incomplete + post_uninstall: Incomplete + prep: Incomplete + provides: Incomplete + requires: Incomplete + conflicts: Incomplete + build_requires: Incomplete + obsoletes: Incomplete + keep_temp: int + use_rpm_opt_flags: int + rpm3_mode: int + no_autoreq: int + force_arch: Incomplete + quiet: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def finalize_package_data(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/build.pyi b/typings/distutils-stubs/command/build.pyi new file mode 100644 index 0000000000..59cbdf3d18 --- /dev/null +++ b/typings/distutils-stubs/command/build.pyi @@ -0,0 +1,33 @@ +from collections.abc import Callable +from typing import ClassVar + +from _typeshed import Incomplete, Unused + +from ..cmd import Command + +def show_compilers() -> None: ... + +class build(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + build_base: str + build_purelib: Incomplete + build_platlib: Incomplete + build_lib: Incomplete + build_temp: Incomplete + build_scripts: Incomplete + compiler: Incomplete + plat_name: Incomplete + debug: Incomplete + force: int + executable: Incomplete + parallel: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def has_pure_modules(self): ... + def has_c_libraries(self): ... + def has_ext_modules(self): ... + def has_scripts(self): ... diff --git a/typings/distutils-stubs/command/build_clib.pyi b/typings/distutils-stubs/command/build_clib.pyi new file mode 100644 index 0000000000..75b78a718f --- /dev/null +++ b/typings/distutils-stubs/command/build_clib.pyi @@ -0,0 +1,28 @@ +from collections.abc import Callable +from typing import ClassVar + +from _typeshed import Incomplete, Unused + +from ..cmd import Command + +class build_clib(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + build_clib: Incomplete + build_temp: Incomplete + libraries: Incomplete + include_dirs: Incomplete + define: Incomplete + undef: Incomplete + debug: Incomplete + force: int + compiler: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_library_list(self, libraries) -> None: ... + def get_library_names(self): ... + def get_source_files(self): ... + def build_libraries(self, libraries) -> None: ... diff --git a/typings/distutils-stubs/command/build_ext.pyi b/typings/distutils-stubs/command/build_ext.pyi new file mode 100644 index 0000000000..2b8c49788f --- /dev/null +++ b/typings/distutils-stubs/command/build_ext.pyi @@ -0,0 +1,50 @@ +from collections.abc import Callable +from typing import ClassVar + +from _typeshed import Incomplete, Unused + +from ..cmd import Command +from ..extension import Extension + +class build_ext(Command): + description: str + sep_by: Incomplete + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + extensions: Incomplete + build_lib: Incomplete + plat_name: Incomplete + build_temp: Incomplete + inplace: int + package: Incomplete + include_dirs: Incomplete + define: Incomplete + undef: Incomplete + libraries: Incomplete + library_dirs: Incomplete + rpath: Incomplete + link_objects: Incomplete + debug: Incomplete + force: Incomplete + compiler: Incomplete + swig: Incomplete + swig_cpp: Incomplete + swig_opts: Incomplete + user: Incomplete + parallel: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_extensions_list(self, extensions) -> None: ... + def get_source_files(self): ... + def get_outputs(self): ... + def build_extensions(self) -> None: ... + def build_extension(self, ext) -> None: ... + def swig_sources(self, sources, extension): ... + def find_swig(self): ... + def get_ext_fullpath(self, ext_name: str) -> str: ... + def get_ext_fullname(self, ext_name: str) -> str: ... + def get_ext_filename(self, ext_name: str) -> str: ... + def get_export_symbols(self, ext: Extension) -> list[str]: ... + def get_libraries(self, ext: Extension) -> list[str]: ... diff --git a/typings/distutils-stubs/command/build_py.pyi b/typings/distutils-stubs/command/build_py.pyi new file mode 100644 index 0000000000..628ab5347f --- /dev/null +++ b/typings/distutils-stubs/command/build_py.pyi @@ -0,0 +1,40 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class build_py(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + build_lib: Incomplete + py_modules: Incomplete + package: Incomplete + package_data: Incomplete + package_dir: Incomplete + compile: int + optimize: int + force: Incomplete + def initialize_options(self) -> None: ... + packages: Incomplete + data_files: Incomplete + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_data_files(self): ... + def find_data_files(self, package, src_dir): ... + def build_package_data(self) -> None: ... + def get_package_dir(self, package): ... + def check_package(self, package, package_dir): ... + def check_module(self, module, module_file): ... + def find_package_modules(self, package, package_dir): ... + def find_modules(self): ... + def find_all_modules(self): ... + def get_source_files(self): ... + def get_module_outfile(self, build_dir, package, module): ... + def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... + def build_module(self, module, module_file, package): ... + def build_modules(self) -> None: ... + def build_packages(self) -> None: ... + def byte_compile(self, files) -> None: ... diff --git a/typings/distutils-stubs/command/build_scripts.pyi b/typings/distutils-stubs/command/build_scripts.pyi new file mode 100644 index 0000000000..5ac864d487 --- /dev/null +++ b/typings/distutils-stubs/command/build_scripts.pyi @@ -0,0 +1,22 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +first_line_re: Incomplete + +class build_scripts(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + build_dir: Incomplete + scripts: Incomplete + force: Incomplete + executable: Incomplete + outfiles: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def get_source_files(self): ... + def run(self) -> None: ... + def copy_scripts(self): ... diff --git a/typings/distutils-stubs/command/check.pyi b/typings/distutils-stubs/command/check.pyi new file mode 100644 index 0000000000..55b4da71b7 --- /dev/null +++ b/typings/distutils-stubs/command/check.pyi @@ -0,0 +1,36 @@ +from typing import ClassVar, Final + +from _typeshed import Incomplete +from docutils.utils import Reporter + +from ..cmd import Command + +class SilentReporter(Reporter): + messages: Incomplete + def __init__( + self, + source, + report_level, + halt_level, + stream: Incomplete | None = ..., + debug: bool = False, + encoding: str = ..., + error_handler: str = ..., + ) -> None: ... + def system_message(self, level, message, *children, **kwargs): ... + +HAS_DOCUTILS: Final[bool] + +class check(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + restructuredtext: int + metadata: int + strict: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def warn(self, msg): ... + def run(self) -> None: ... + def check_metadata(self) -> None: ... + def check_restructuredtext(self) -> None: ... diff --git a/typings/distutils-stubs/command/clean.pyi b/typings/distutils-stubs/command/clean.pyi new file mode 100644 index 0000000000..2b78d86031 --- /dev/null +++ b/typings/distutils-stubs/command/clean.pyi @@ -0,0 +1,19 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class clean(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + build_base: Incomplete + build_lib: Incomplete + build_temp: Incomplete + build_scripts: Incomplete + bdist_base: Incomplete + all: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/config.pyi b/typings/distutils-stubs/command/config.pyi new file mode 100644 index 0000000000..3145141849 --- /dev/null +++ b/typings/distutils-stubs/command/config.pyi @@ -0,0 +1,93 @@ +from collections.abc import Sequence +from re import Pattern +from typing import ClassVar, Final + +from _typeshed import Incomplete, StrOrBytesPath + +from ..ccompiler import CCompiler +from ..cmd import Command + +LANG_EXT: Final[dict[str, str]] + +class config(Command): + description: str + # Tuple is full name, short name, description + user_options: ClassVar[list[tuple[str, str | None, str]]] + compiler: str | CCompiler + cc: str | None + include_dirs: Sequence[str] | None + libraries: Sequence[str] | None + library_dirs: Sequence[str] | None + noisy: int + dump_source: int + temp_files: Sequence[str] + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def try_cpp( + self, + body: str | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def search_cpp( + self, + pattern: Pattern[str] | str, + body: str | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def try_compile( + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def try_link( + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def try_run( + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def check_func( + self, + func: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + decl: bool = False, + call: bool = False, + ) -> bool: ... + def check_lib( + self, + library: str, + library_dirs: Sequence[str] | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + other_libraries: list[str] = [], + ) -> bool: ... + def check_header( + self, + header: str, + include_dirs: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + +def dump_file(filename: StrOrBytesPath, head: Incomplete | None = None) -> None: ... diff --git a/typings/distutils-stubs/command/install.pyi b/typings/distutils-stubs/command/install.pyi new file mode 100644 index 0000000000..798e30ae27 --- /dev/null +++ b/typings/distutils-stubs/command/install.pyi @@ -0,0 +1,60 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + prefix: str | None + exec_prefix: Incomplete + home: str | None + user: bool + install_base: Incomplete + install_platbase: Incomplete + root: str | None + install_purelib: Incomplete + install_platlib: Incomplete + install_headers: Incomplete + install_lib: str | None + install_scripts: Incomplete + install_data: Incomplete + install_userbase: Incomplete + install_usersite: Incomplete + compile: Incomplete + optimize: Incomplete + extra_path: Incomplete + install_path_file: int + force: int + skip_build: int + warn_dir: int + build_base: Incomplete + build_lib: Incomplete + record: Incomplete + def initialize_options(self) -> None: ... + config_vars: Incomplete + install_libbase: Incomplete + def finalize_options(self) -> None: ... + def dump_dirs(self, msg) -> None: ... + def finalize_unix(self) -> None: ... + def finalize_other(self) -> None: ... + def select_scheme(self, name) -> None: ... + def expand_basedirs(self) -> None: ... + def expand_dirs(self) -> None: ... + def convert_paths(self, *names) -> None: ... + path_file: Incomplete + extra_dirs: Incomplete + def handle_extra_path(self) -> None: ... + def change_roots(self, *names) -> None: ... + def create_home_path(self) -> None: ... + def run(self) -> None: ... + def create_path_file(self) -> None: ... + def get_outputs(self): ... + def get_inputs(self): ... + def has_lib(self): ... + def has_headers(self): ... + def has_scripts(self): ... + def has_data(self): ... diff --git a/typings/distutils-stubs/command/install_data.pyi b/typings/distutils-stubs/command/install_data.pyi new file mode 100644 index 0000000000..8cc23f08db --- /dev/null +++ b/typings/distutils-stubs/command/install_data.pyi @@ -0,0 +1,21 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install_data(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Incomplete + outfiles: Incomplete + root: Incomplete + force: int + data_files: Incomplete + warn_dir: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/install_egg_info.pyi b/typings/distutils-stubs/command/install_egg_info.pyi new file mode 100644 index 0000000000..fdc0cf982a --- /dev/null +++ b/typings/distutils-stubs/command/install_egg_info.pyi @@ -0,0 +1,20 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install_egg_info(Command): + description: ClassVar[str] + user_options: ClassVar[list[tuple[str, str, str]]] + install_dir: Incomplete + def initialize_options(self) -> None: ... + target: Incomplete + outputs: Incomplete + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_outputs(self) -> list[str]: ... + +def safe_name(name): ... +def safe_version(version): ... +def to_filename(name): ... diff --git a/typings/distutils-stubs/command/install_headers.pyi b/typings/distutils-stubs/command/install_headers.pyi new file mode 100644 index 0000000000..dc1243a3f7 --- /dev/null +++ b/typings/distutils-stubs/command/install_headers.pyi @@ -0,0 +1,18 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install_headers(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Incomplete + force: int + outfiles: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/install_lib.pyi b/typings/distutils-stubs/command/install_lib.pyi new file mode 100644 index 0000000000..1189464ae1 --- /dev/null +++ b/typings/distutils-stubs/command/install_lib.pyi @@ -0,0 +1,25 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install_lib(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + install_dir: Incomplete + build_dir: Incomplete + force: int + compile: Incomplete + optimize: Incomplete + skip_build: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def build(self) -> None: ... + def install(self) -> list[str]: ... + def byte_compile(self, files) -> None: ... + def get_outputs(self): ... + def get_inputs(self): ... diff --git a/typings/distutils-stubs/command/install_scripts.pyi b/typings/distutils-stubs/command/install_scripts.pyi new file mode 100644 index 0000000000..a87284e842 --- /dev/null +++ b/typings/distutils-stubs/command/install_scripts.pyi @@ -0,0 +1,20 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..cmd import Command + +class install_scripts(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Incomplete + force: int + build_dir: Incomplete + skip_build: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + outfiles: list[str] + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/register.pyi b/typings/distutils-stubs/command/register.pyi new file mode 100644 index 0000000000..bb9d6c2e38 --- /dev/null +++ b/typings/distutils-stubs/command/register.pyi @@ -0,0 +1,24 @@ +from collections.abc import Callable +from typing import Any, ClassVar + +from _typeshed import Incomplete + +from ..config import PyPIRCCommand + +class register(PyPIRCCommand): + description: str + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] + list_classifiers: int + strict: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_metadata(self) -> None: ... + def classifiers(self) -> None: ... + def verify_metadata(self) -> None: ... + def send_metadata(self) -> None: ... + def build_post_data(self, action): ... + def post_to_server( + self, data, auth: Incomplete | None = None + ) -> tuple[int, str]: ... diff --git a/typings/distutils-stubs/command/sdist.pyi b/typings/distutils-stubs/command/sdist.pyi new file mode 100644 index 0000000000..94a80cc8cb --- /dev/null +++ b/typings/distutils-stubs/command/sdist.pyi @@ -0,0 +1,47 @@ +from collections.abc import Callable +from typing import ClassVar + +from _typeshed import Incomplete, Unused + +from ..cmd import Command + +def show_formats() -> None: ... + +class sdist(Command): + description: ClassVar[str] + + def checking_metadata(self): ... + + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + negative_opt: ClassVar[dict[str, str]] + READMES: ClassVar[tuple[str, ...]] + template: Incomplete + manifest: Incomplete + use_defaults: int + prune: int + manifest_only: int + force_manifest: int + formats: Incomplete + keep_temp: int + dist_dir: Incomplete + archive_files: Incomplete + metadata_check: int + owner: Incomplete + group: Incomplete + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + filelist: Incomplete + def run(self) -> None: ... + def get_file_list(self) -> None: ... + def add_defaults(self) -> None: ... + def read_template(self) -> None: ... + def prune_file_list(self) -> None: ... + def write_manifest(self) -> None: ... + def read_manifest(self) -> None: ... + def make_release_tree(self, base_dir, files) -> None: ... + def make_distribution(self) -> None: ... + def get_archive_files(self): ... + +def is_comment(line: str) -> bool: ... diff --git a/typings/distutils-stubs/command/upload.pyi b/typings/distutils-stubs/command/upload.pyi new file mode 100644 index 0000000000..a78f777ba7 --- /dev/null +++ b/typings/distutils-stubs/command/upload.pyi @@ -0,0 +1,19 @@ +from typing import ClassVar + +from _typeshed import Incomplete + +from ..config import PyPIRCCommand + +class upload(PyPIRCCommand): + description: ClassVar[str] + username: str + password: str + show_response: int + sign: bool + identity: Incomplete + def initialize_options(self) -> None: ... + repository: Incomplete + realm: Incomplete + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def upload_file(self, command: str, pyversion: str, filename: str) -> None: ... diff --git a/typings/distutils-stubs/compat/__init__.pyi b/typings/distutils-stubs/compat/__init__.pyi new file mode 100644 index 0000000000..39acc295d7 --- /dev/null +++ b/typings/distutils-stubs/compat/__init__.pyi @@ -0,0 +1 @@ +def consolidate_linker_args(args: list[str]) -> str | list[str]: ... diff --git a/typings/distutils-stubs/config.pyi b/typings/distutils-stubs/config.pyi new file mode 100644 index 0000000000..28ca344d9b --- /dev/null +++ b/typings/distutils-stubs/config.pyi @@ -0,0 +1,18 @@ +from abc import abstractmethod +from typing import ClassVar + +from .cmd import Command + +DEFAULT_PYPIRC: str + +class PyPIRCCommand(Command): + DEFAULT_REPOSITORY: ClassVar[str] + DEFAULT_REALM: ClassVar[str] + repository: None + realm: None + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + @abstractmethod + def run(self) -> None: ... diff --git a/typings/distutils-stubs/core.pyi b/typings/distutils-stubs/core.pyi new file mode 100644 index 0000000000..f519706a5d --- /dev/null +++ b/typings/distutils-stubs/core.pyi @@ -0,0 +1,62 @@ +from collections.abc import Mapping +from typing import Final + +from _typeshed import Incomplete, StrOrBytesPath + +from .cmd import Command as Command +from .dist import Distribution as Distribution +from .extension import Extension as Extension + +USAGE: Final[str] + +def gen_usage(script_name: StrOrBytesPath) -> str: ... + +setup_keywords: tuple[str, ...] +extension_keywords: tuple[str, ...] + +def setup( + *, + name: str = ..., + version: str = ..., + description: str = ..., + long_description: str = ..., + author: str = ..., + author_email: str = ..., + maintainer: str = ..., + maintainer_email: str = ..., + url: str = ..., + download_url: str = ..., + packages: list[str] = ..., + py_modules: list[str] = ..., + scripts: list[str] = ..., + ext_modules: list[Extension] = ..., + classifiers: list[str] = ..., + distclass: type[Distribution] = ..., + script_name: str = ..., + script_args: list[str] = ..., + options: Mapping[str, Incomplete] = ..., + license: str = ..., + keywords: list[str] | str = ..., + platforms: list[str] | str = ..., + cmdclass: Mapping[str, type[Command]] = ..., + data_files: list[tuple[str, list[str]]] = ..., + package_dir: Mapping[str, str] = ..., + obsoletes: list[str] = ..., + provides: list[str] = ..., + requires: list[str] = ..., + command_packages: list[str] = ..., + command_options: Mapping[str, Mapping[str, tuple[Incomplete, Incomplete]]] = ..., + package_data: Mapping[str, list[str]] = ..., + include_package_data: bool = ..., + libraries: list[str] = ..., + headers: list[str] = ..., + ext_package: str = ..., + include_dirs: list[str] = ..., + password: str = ..., + fullname: str = ..., + # Custom Distributions could accept more params + **attrs: object, +) -> Distribution: ... +def run_setup( + script_name: str, script_args: list[str] | None = None, stop_after: str = "run" +) -> Distribution: ... diff --git a/typings/distutils-stubs/cygwinccompiler.pyi b/typings/distutils-stubs/cygwinccompiler.pyi new file mode 100644 index 0000000000..20dfabc443 --- /dev/null +++ b/typings/distutils-stubs/cygwinccompiler.pyi @@ -0,0 +1,21 @@ +from re import Pattern +from typing import Final, Literal + +from .unixccompiler import UnixCCompiler +from .version import LooseVersion + +def get_msvcr() -> list[str] | None: ... + +class CygwinCCompiler(UnixCCompiler): ... +class Mingw32CCompiler(CygwinCCompiler): ... + +CONFIG_H_OK: Final = "ok" +CONFIG_H_NOTOK: Final = "not ok" +CONFIG_H_UNCERTAIN: Final = "uncertain" + +def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ... + +RE_VERSION: Final[Pattern[bytes]] + +def get_versions() -> tuple[LooseVersion | None, ...]: ... +def is_cygwingcc() -> bool: ... diff --git a/typings/distutils-stubs/debug.pyi b/typings/distutils-stubs/debug.pyi new file mode 100644 index 0000000000..30095883b0 --- /dev/null +++ b/typings/distutils-stubs/debug.pyi @@ -0,0 +1,3 @@ +from typing import Final + +DEBUG: Final[str | None] diff --git a/typings/distutils-stubs/dep_util.pyi b/typings/distutils-stubs/dep_util.pyi new file mode 100644 index 0000000000..518d6c7ebe --- /dev/null +++ b/typings/distutils-stubs/dep_util.pyi @@ -0,0 +1,5 @@ +from ._modified import ( + newer as newer, + newer_group as newer_group, + newer_pairwise as newer_pairwise, +) diff --git a/typings/distutils-stubs/dir_util.pyi b/typings/distutils-stubs/dir_util.pyi new file mode 100644 index 0000000000..b77b7ef632 --- /dev/null +++ b/typings/distutils-stubs/dir_util.pyi @@ -0,0 +1,30 @@ +from collections.abc import Iterable + +from _typeshed import StrOrBytesPath, StrPath + +def mkpath( + name: str, + mode: int = 0o777, + verbose: bool = True, + dry_run: bool = False, +) -> list[str]: ... +def create_tree( + base_dir: StrPath, + files: Iterable[StrPath], + mode: int = 0o777, + verbose: bool = True, + dry_run: bool = False, +) -> None: ... +def copy_tree( + src: StrPath, + dst: str, + preserve_mode: bool = True, + preserve_times: bool = True, + preserve_symlinks: bool = False, + update: bool = False, + verbose: bool = True, + dry_run: bool = False, +) -> list[str]: ... +def remove_tree( + directory: StrOrBytesPath, verbose: bool = True, dry_run: bool = False +) -> None: ... diff --git a/typings/distutils-stubs/dist.pyi b/typings/distutils-stubs/dist.pyi new file mode 100644 index 0000000000..bc6486c780 --- /dev/null +++ b/typings/distutils-stubs/dist.pyi @@ -0,0 +1,426 @@ +from collections.abc import Iterable, MutableMapping +from re import Pattern +from typing import IO, ClassVar, Literal, TypeVar, overload + +from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite +from typing_extensions import TypeAlias + +from .cmd import Command +from .command.bdist import bdist +from .command.bdist_dumb import bdist_dumb +from .command.bdist_rpm import bdist_rpm +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.build_scripts import build_scripts +from .command.check import check +from .command.clean import clean +from .command.config import config +from .command.install import install +from .command.install_data import install_data +from .command.install_egg_info import install_egg_info +from .command.install_headers import install_headers +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.sdist import sdist +from .command.upload import upload + +command_re: Pattern[str] + +_OptionsList: TypeAlias = list[ + tuple[str, str | None, str, int] | tuple[str, str | None, str] +] +_CommandT = TypeVar("_CommandT", bound=Command) + +class DistributionMetadata: + def __init__(self, path: StrOrBytesPath | None = None) -> None: ... + name: str | None + version: str | None + author: str | None + author_email: str | None + maintainer: str | None + maintainer_email: str | None + url: str | None + license: str | None + description: str | None + long_description: str | None + keywords: str | list[str] | None + platforms: str | list[str] | None + classifiers: str | list[str] | None + download_url: str | None + provides: list[str] | None + requires: list[str] | None + obsoletes: list[str] | None + def read_pkg_file(self, file: IO[str]) -> None: ... + def write_pkg_info(self, base_dir: StrPath) -> None: ... + def write_pkg_file(self, file: SupportsWrite[str]) -> None: ... + def get_name(self) -> str: ... + def get_version(self) -> str: ... + def get_fullname(self) -> str: ... + def get_author(self) -> str: ... + def get_author_email(self) -> str: ... + def get_maintainer(self) -> str: ... + def get_maintainer_email(self) -> str: ... + def get_contact(self) -> str: ... + def get_contact_email(self) -> str: ... + def get_url(self) -> str: ... + def get_license(self) -> str: ... + def get_licence(self) -> str: ... + def get_description(self) -> str: ... + def get_long_description(self) -> str: ... + def get_keywords(self) -> str | list[str]: ... + def get_platforms(self) -> str | list[str]: ... + def get_classifiers(self) -> str | list[str]: ... + def get_download_url(self) -> str: ... + def get_requires(self) -> list[str]: ... + def set_requires(self, value: Iterable[str]) -> None: ... + def get_provides(self) -> list[str]: ... + def set_provides(self, value: Iterable[str]) -> None: ... + def get_obsoletes(self) -> list[str]: ... + def set_obsoletes(self, value: Iterable[str]) -> None: ... + +class Distribution: + cmdclass: dict[str, type[Command]] + metadata: DistributionMetadata + def __init__( + self, attrs: MutableMapping[str, Incomplete] | None = None + ) -> None: ... + def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... + def parse_config_files( + self, filenames: Iterable[StrPath] | None = None + ) -> None: ... + global_options: ClassVar[_OptionsList] + common_usage: ClassVar[str] + display_options: ClassVar[_OptionsList] + display_option_names: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + verbose: bool + dry_run: bool + help: bool + command_packages: list[str] | None + script_name: str | None + script_args: list[str] | None + command_options: dict[str, dict[str, tuple[str, str]]] + dist_files: list[tuple[str, str, str]] + packages: Incomplete + package_data: dict[str, list[str]] + package_dir: Incomplete + py_modules: Incomplete + libraries: Incomplete + headers: Incomplete + ext_modules: Incomplete + ext_package: Incomplete + include_dirs: Incomplete + extra_path: Incomplete + scripts: Incomplete + data_files: Incomplete + password: str + command_obj: dict[str, Command] + have_run: dict[str, bool] + want_user_cfg: bool + def dump_option_dicts( + self, + header: Incomplete | None = None, + commands: Incomplete | None = None, + indent: str = "", + ) -> None: ... + def find_config_files(self): ... + commands: Incomplete + def parse_command_line(self): ... + def finalize_options(self) -> None: ... + def handle_display_options(self, option_order): ... + def print_command_list(self, commands, header, max_length) -> None: ... + def print_commands(self) -> None: ... + def get_command_list(self): ... + def get_command_packages(self): ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_command_obj( + self, command: Literal["bdist"], create: Literal[True] = True + ) -> bdist: ... + @overload + def get_command_obj( + self, command: Literal["bdist_dumb"], create: Literal[True] = True + ) -> bdist_dumb: ... + @overload + def get_command_obj( + self, command: Literal["bdist_rpm"], create: Literal[True] = True + ) -> bdist_rpm: ... + @overload + def get_command_obj( + self, command: Literal["build"], create: Literal[True] = True + ) -> build: ... + @overload + def get_command_obj( + self, command: Literal["build_clib"], create: Literal[True] = True + ) -> build_clib: ... + @overload + def get_command_obj( + self, command: Literal["build_ext"], create: Literal[True] = True + ) -> build_ext: ... + @overload + def get_command_obj( + self, command: Literal["build_py"], create: Literal[True] = True + ) -> build_py: ... + @overload + def get_command_obj( + self, command: Literal["build_scripts"], create: Literal[True] = True + ) -> build_scripts: ... + @overload + def get_command_obj( + self, command: Literal["check"], create: Literal[True] = True + ) -> check: ... + @overload + def get_command_obj( + self, command: Literal["clean"], create: Literal[True] = True + ) -> clean: ... + @overload + def get_command_obj( + self, command: Literal["config"], create: Literal[True] = True + ) -> config: ... + @overload + def get_command_obj( + self, command: Literal["install"], create: Literal[True] = True + ) -> install: ... + @overload + def get_command_obj( + self, command: Literal["install_data"], create: Literal[True] = True + ) -> install_data: ... + @overload + def get_command_obj( + self, command: Literal["install_egg_info"], create: Literal[True] = True + ) -> install_egg_info: ... + @overload + def get_command_obj( + self, command: Literal["install_headers"], create: Literal[True] = True + ) -> install_headers: ... + @overload + def get_command_obj( + self, command: Literal["install_lib"], create: Literal[True] = True + ) -> install_lib: ... + @overload + def get_command_obj( + self, command: Literal["install_scripts"], create: Literal[True] = True + ) -> install_scripts: ... + @overload + def get_command_obj( + self, command: Literal["register"], create: Literal[True] = True + ) -> register: ... + @overload + def get_command_obj( + self, command: Literal["sdist"], create: Literal[True] = True + ) -> sdist: ... + @overload + def get_command_obj( + self, command: Literal["upload"], create: Literal[True] = True + ) -> upload: ... + @overload + def get_command_obj( + self, command: str, create: Literal[True] = True + ) -> Command: ... + # Not replicating the overloads for "Command | None", user may use "isinstance" + @overload + def get_command_obj( + self, command: str, create: Literal[False] + ) -> Command | None: ... + @overload + def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ... + @overload + def get_command_class(self, command: Literal["bdist_dumb"]) -> type[bdist_dumb]: ... + @overload + def get_command_class(self, command: Literal["bdist_rpm"]) -> type[bdist_rpm]: ... + @overload + def get_command_class(self, command: Literal["build"]) -> type[build]: ... + @overload + def get_command_class(self, command: Literal["build_clib"]) -> type[build_clib]: ... + @overload + def get_command_class(self, command: Literal["build_ext"]) -> type[build_ext]: ... + @overload + def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ... + @overload + def get_command_class( + self, command: Literal["build_scripts"] + ) -> type[build_scripts]: ... + @overload + def get_command_class(self, command: Literal["check"]) -> type[check]: ... + @overload + def get_command_class(self, command: Literal["clean"]) -> type[clean]: ... + @overload + def get_command_class(self, command: Literal["config"]) -> type[config]: ... + @overload + def get_command_class(self, command: Literal["install"]) -> type[install]: ... + @overload + def get_command_class( + self, command: Literal["install_data"] + ) -> type[install_data]: ... + @overload + def get_command_class( + self, command: Literal["install_egg_info"] + ) -> type[install_egg_info]: ... + @overload + def get_command_class( + self, command: Literal["install_headers"] + ) -> type[install_headers]: ... + @overload + def get_command_class( + self, command: Literal["install_lib"] + ) -> type[install_lib]: ... + @overload + def get_command_class( + self, command: Literal["install_scripts"] + ) -> type[install_scripts]: ... + @overload + def get_command_class(self, command: Literal["register"]) -> type[register]: ... + @overload + def get_command_class(self, command: Literal["sdist"]) -> type[sdist]: ... + @overload + def get_command_class(self, command: Literal["upload"]) -> type[upload]: ... + @overload + def get_command_class(self, command: str) -> type[Command]: ... + @overload + def reinitialize_command( + self, command: Literal["bdist"], reinit_subcommands: bool = False + ) -> bdist: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False + ) -> bdist_dumb: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False + ) -> bdist_rpm: ... + @overload + def reinitialize_command( + self, command: Literal["build"], reinit_subcommands: bool = False + ) -> build: ... + @overload + def reinitialize_command( + self, command: Literal["build_clib"], reinit_subcommands: bool = False + ) -> build_clib: ... + @overload + def reinitialize_command( + self, command: Literal["build_ext"], reinit_subcommands: bool = False + ) -> build_ext: ... + @overload + def reinitialize_command( + self, command: Literal["build_py"], reinit_subcommands: bool = False + ) -> build_py: ... + @overload + def reinitialize_command( + self, command: Literal["build_scripts"], reinit_subcommands: bool = False + ) -> build_scripts: ... + @overload + def reinitialize_command( + self, command: Literal["check"], reinit_subcommands: bool = False + ) -> check: ... + @overload + def reinitialize_command( + self, command: Literal["clean"], reinit_subcommands: bool = False + ) -> clean: ... + @overload + def reinitialize_command( + self, command: Literal["config"], reinit_subcommands: bool = False + ) -> config: ... + @overload + def reinitialize_command( + self, command: Literal["install"], reinit_subcommands: bool = False + ) -> install: ... + @overload + def reinitialize_command( + self, command: Literal["install_data"], reinit_subcommands: bool = False + ) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False + ) -> install_egg_info: ... + @overload + def reinitialize_command( + self, command: Literal["install_headers"], reinit_subcommands: bool = False + ) -> install_headers: ... + @overload + def reinitialize_command( + self, command: Literal["install_lib"], reinit_subcommands: bool = False + ) -> install_lib: ... + @overload + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool = False + ) -> install_scripts: ... + @overload + def reinitialize_command( + self, command: Literal["register"], reinit_subcommands: bool = False + ) -> register: ... + @overload + def reinitialize_command( + self, command: Literal["sdist"], reinit_subcommands: bool = False + ) -> sdist: ... + @overload + def reinitialize_command( + self, command: Literal["upload"], reinit_subcommands: bool = False + ) -> upload: ... + @overload + def reinitialize_command( + self, command: str, reinit_subcommands: bool = False + ) -> Command: ... + @overload + def reinitialize_command( + self, command: _CommandT, reinit_subcommands: bool = False + ) -> _CommandT: ... + def announce(self, msg, level: int = 20) -> None: ... + def run_commands(self) -> None: ... + def run_command(self, command: str) -> None: ... + def has_pure_modules(self) -> bool: ... + def has_ext_modules(self) -> bool: ... + def has_c_libraries(self) -> bool: ... + def has_modules(self) -> bool: ... + def has_headers(self) -> bool: ... + def has_scripts(self) -> bool: ... + def has_data_files(self) -> bool: ... + def is_pure(self) -> bool: ... + + # Default getter methods generated in __init__ from self.metadata._METHOD_BASENAMES + def get_name(self) -> str: ... + def get_version(self) -> str: ... + def get_fullname(self) -> str: ... + def get_author(self) -> str: ... + def get_author_email(self) -> str: ... + def get_maintainer(self) -> str: ... + def get_maintainer_email(self) -> str: ... + def get_contact(self) -> str: ... + def get_contact_email(self) -> str: ... + def get_url(self) -> str: ... + def get_license(self) -> str: ... + def get_licence(self) -> str: ... + def get_description(self) -> str: ... + def get_long_description(self) -> str: ... + def get_keywords(self) -> str | list[str]: ... + def get_platforms(self) -> str | list[str]: ... + def get_classifiers(self) -> str | list[str]: ... + def get_download_url(self) -> str: ... + def get_requires(self) -> list[str]: ... + def get_provides(self) -> list[str]: ... + def get_obsoletes(self) -> list[str]: ... + + # Default attributes generated in __init__ from self.display_option_names + help_commands: bool + name: str | Literal[False] + version: str | Literal[False] + fullname: str | Literal[False] + author: str | Literal[False] + author_email: str | Literal[False] + maintainer: str | Literal[False] + maintainer_email: str | Literal[False] + contact: str | Literal[False] + contact_email: str | Literal[False] + url: str | Literal[False] + license: str | Literal[False] + licence: str | Literal[False] + description: str | Literal[False] + long_description: str | Literal[False] + platforms: str | list[str] | Literal[False] + classifiers: str | list[str] | Literal[False] + keywords: str | list[str] | Literal[False] + provides: list[str] | Literal[False] + requires: list[str] | Literal[False] + obsoletes: list[str] | Literal[False] diff --git a/typings/distutils-stubs/errors.pyi b/typings/distutils-stubs/errors.pyi new file mode 100644 index 0000000000..e483362bfb --- /dev/null +++ b/typings/distutils-stubs/errors.pyi @@ -0,0 +1,19 @@ +class DistutilsError(Exception): ... +class DistutilsModuleError(DistutilsError): ... +class DistutilsClassError(DistutilsError): ... +class DistutilsGetoptError(DistutilsError): ... +class DistutilsArgError(DistutilsError): ... +class DistutilsFileError(DistutilsError): ... +class DistutilsOptionError(DistutilsError): ... +class DistutilsSetupError(DistutilsError): ... +class DistutilsPlatformError(DistutilsError): ... +class DistutilsExecError(DistutilsError): ... +class DistutilsInternalError(DistutilsError): ... +class DistutilsTemplateError(DistutilsError): ... +class DistutilsByteCompileError(DistutilsError): ... +class CCompilerError(Exception): ... +class PreprocessError(CCompilerError): ... +class CompileError(CCompilerError): ... +class LibError(CCompilerError): ... +class LinkError(CCompilerError): ... +class UnknownFileError(CCompilerError): ... diff --git a/typings/distutils-stubs/extension.pyi b/typings/distutils-stubs/extension.pyi new file mode 100644 index 0000000000..789bbf6ec3 --- /dev/null +++ b/typings/distutils-stubs/extension.pyi @@ -0,0 +1,36 @@ +class Extension: + name: str + sources: list[str] + include_dirs: list[str] + define_macros: list[tuple[str, str | None]] + undef_macros: list[str] + library_dirs: list[str] + libraries: list[str] + runtime_library_dirs: list[str] + extra_objects: list[str] + extra_compile_args: list[str] + extra_link_args: list[str] + export_symbols: list[str] + swig_opts: list[str] + depends: list[str] + language: str | None + optional: bool | None + def __init__( + self, + name: str, + sources: list[str], + include_dirs: list[str] | None = None, + define_macros: list[tuple[str, str | None]] | None = None, + undef_macros: list[str] | None = None, + library_dirs: list[str] | None = None, + libraries: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + extra_objects: list[str] | None = None, + extra_compile_args: list[str] | None = None, + extra_link_args: list[str] | None = None, + export_symbols: list[str] | None = None, + swig_opts: list[str] | None = None, + depends: list[str] | None = None, + language: str | None = None, + optional: bool | None = None, + ) -> None: ... diff --git a/typings/distutils-stubs/fancy_getopt.pyi b/typings/distutils-stubs/fancy_getopt.pyi new file mode 100644 index 0000000000..f51921b607 --- /dev/null +++ b/typings/distutils-stubs/fancy_getopt.pyi @@ -0,0 +1,38 @@ +from collections.abc import Iterable, Mapping +from re import Pattern +from typing import Any, Final, overload + +from typing_extensions import TypeAlias + +_Option: TypeAlias = tuple[str, str | None, str] +_GR: TypeAlias = tuple[list[str], OptionDummy] + +longopt_pat: Final = r"[a-zA-Z](?:[a-zA-Z0-9-]*)" +longopt_re: Final[Pattern[str]] +neg_alias_re: Final[Pattern[str]] +longopt_xlate: Final[dict[int, int]] + +class FancyGetopt: + def __init__(self, option_table: list[_Option] | None = None) -> None: ... + # TODO kinda wrong, `getopt(object=object())` is invalid + @overload + def getopt(self, args: list[str] | None = None) -> _GR: ... + @overload + def getopt(self, args: list[str] | None, object: Any) -> list[str]: ... + def get_option_order(self) -> list[tuple[str, str]]: ... + def generate_help(self, header: str | None = None) -> list[str]: ... + +def fancy_getopt( + options: list[_Option], + negative_opt: Mapping[_Option, _Option], + object: Any, + args: list[str] | None, +) -> list[str] | _GR: ... + +WS_TRANS: Final[dict[int, str]] + +def wrap_text(text: str, width: int) -> list[str]: ... +def translate_longopt(opt: str) -> str: ... + +class OptionDummy: + def __init__(self, options: Iterable[str] = []) -> None: ... diff --git a/typings/distutils-stubs/file_util.pyi b/typings/distutils-stubs/file_util.pyi new file mode 100644 index 0000000000..5720ff28af --- /dev/null +++ b/typings/distutils-stubs/file_util.pyi @@ -0,0 +1,45 @@ +from collections.abc import Iterable +from typing import TypeVar, overload + +from _typeshed import BytesPath, StrOrBytesPath, StrPath + +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) + +@overload +def copy_file( + src: StrPath, + dst: _StrPathT, + preserve_mode: bool = True, + preserve_times: bool = True, + update: bool = False, + link: str | None = None, + verbose: bool = True, + dry_run: bool = False, +) -> tuple[_StrPathT | str, bool]: ... +@overload +def copy_file( + src: BytesPath, + dst: _BytesPathT, + preserve_mode: bool = True, + preserve_times: bool = True, + update: bool = False, + link: str | None = None, + verbose: bool = True, + dry_run: bool = False, +) -> tuple[_BytesPathT | bytes, bool]: ... +@overload +def move_file( + src: StrPath, + dst: _StrPathT, + verbose: bool = False, + dry_run: bool = False, +) -> _StrPathT | str: ... +@overload +def move_file( + src: BytesPath, + dst: _BytesPathT, + verbose: bool = False, + dry_run: bool = False, +) -> _BytesPathT | bytes: ... +def write_file(filename: StrOrBytesPath, contents: Iterable[str]) -> None: ... diff --git a/typings/distutils-stubs/filelist.pyi b/typings/distutils-stubs/filelist.pyi new file mode 100644 index 0000000000..0ca877eb17 --- /dev/null +++ b/typings/distutils-stubs/filelist.pyi @@ -0,0 +1,57 @@ +from collections.abc import Iterable +from re import Pattern +from typing import Literal, overload + +# class is entirely undocumented +class FileList: + allfiles: Iterable[str] | None + files: list[str] + def __init__(self, warn: None = None, debug_print: None = None) -> None: ... + def set_allfiles(self, allfiles: Iterable[str]) -> None: ... + def findall(self, dir: str = ...) -> None: ... + def debug_print(self, msg: str) -> None: ... + def append(self, item: str) -> None: ... + def extend(self, items: Iterable[str]) -> None: ... + def sort(self) -> None: ... + def remove_duplicates(self) -> None: ... + def process_template_line(self, line: str) -> None: ... + @overload + def include_pattern( + self, + pattern: str, + anchor: bool = True, + prefix: str | None = None, + is_regex: Literal[False] = False, + ) -> bool: ... + @overload + def include_pattern( + self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] + ) -> bool: ... + @overload + def include_pattern( + self, + pattern: str | Pattern[str], + anchor: bool = True, + prefix: str | None = None, + is_regex: bool = False, + ) -> bool: ... + @overload + def exclude_pattern( + self, + pattern: str, + anchor: bool = True, + prefix: str | None = None, + is_regex: Literal[False] = False, + ) -> bool: ... + @overload + def exclude_pattern( + self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] + ) -> bool: ... + @overload + def exclude_pattern( + self, + pattern: str | Pattern[str], + anchor: bool = True, + prefix: str | None = None, + is_regex: bool = False, + ) -> bool: ... diff --git a/typings/distutils-stubs/log.pyi b/typings/distutils-stubs/log.pyi new file mode 100644 index 0000000000..5d113cb11c --- /dev/null +++ b/typings/distutils-stubs/log.pyi @@ -0,0 +1,25 @@ +from typing import Final + +DEBUG: Final = 1 +INFO: Final = 2 +WARN: Final = 3 +ERROR: Final = 4 +FATAL: Final = 5 + +class Log: + def __init__(self, threshold: int = 3) -> None: ... + def log(self, level: int, msg: str, *args: object) -> None: ... + def debug(self, msg: str, *args: object) -> None: ... + def info(self, msg: str, *args: object) -> None: ... + def warn(self, msg: str, *args: object) -> None: ... + def error(self, msg: str, *args: object) -> None: ... + def fatal(self, msg: str, *args: object) -> None: ... + +def log(level: int, msg: str, *args: object) -> None: ... +def debug(msg: str, *args: object) -> None: ... +def info(msg: str, *args: object) -> None: ... +def warn(msg: str, *args: object) -> None: ... +def error(msg: str, *args: object) -> None: ... +def fatal(msg: str, *args: object) -> None: ... +def set_threshold(level: int) -> int: ... +def set_verbosity(v: int) -> None: ... diff --git a/typings/distutils-stubs/msvccompiler.pyi b/typings/distutils-stubs/msvccompiler.pyi new file mode 100644 index 0000000000..26289a9a1f --- /dev/null +++ b/typings/distutils-stubs/msvccompiler.pyi @@ -0,0 +1,3 @@ +from .ccompiler import CCompiler + +class MSVCCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/spawn.pyi b/typings/distutils-stubs/spawn.pyi new file mode 100644 index 0000000000..4f849bd2d2 --- /dev/null +++ b/typings/distutils-stubs/spawn.pyi @@ -0,0 +1,7 @@ +def spawn( + cmd: list[str], + search_path: bool = True, + verbose: bool = False, + dry_run: bool = False, +) -> None: ... +def find_executable(executable: str, path: str | None = None) -> str | None: ... diff --git a/typings/distutils-stubs/sysconfig.pyi b/typings/distutils-stubs/sysconfig.pyi new file mode 100644 index 0000000000..f7762602bd --- /dev/null +++ b/typings/distutils-stubs/sysconfig.pyi @@ -0,0 +1,29 @@ +from typing import Final, Literal, overload + +from _typeshed import MaybeNone +from typing_extensions import deprecated + +from setuptools._distutils.ccompiler import CCompiler + +PREFIX: Final[str] +EXEC_PREFIX: Final[str] +_config_vars: dict[str, str] | MaybeNone + +@overload +@deprecated( + "SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11" +) +def get_config_var(name: Literal["SO"]) -> int | str | None: ... +@overload +def get_config_var(name: str) -> int | str | None: ... +@overload +def get_config_vars() -> dict[str, str | int]: ... +@overload +def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ... +def get_config_h_filename() -> str: ... +def get_makefile_filename() -> str: ... +def get_python_inc(plat_specific: bool = False, prefix: str | None = None) -> str: ... +def get_python_lib( + plat_specific: bool = False, standard_lib: bool = False, prefix: str | None = None +) -> str: ... +def customize_compiler(compiler: CCompiler) -> None: ... diff --git a/typings/distutils-stubs/text_file.pyi b/typings/distutils-stubs/text_file.pyi new file mode 100644 index 0000000000..8dce428941 --- /dev/null +++ b/typings/distutils-stubs/text_file.pyi @@ -0,0 +1,23 @@ +from typing import IO + +class TextFile: + def __init__( + self, + filename: str | None = None, + file: IO[str] | None = None, + *, + strip_comments: bool = ..., + lstrip_ws: bool = ..., + rstrip_ws: bool = ..., + skip_blanks: bool = ..., + join_lines: bool = ..., + collapse_join: bool = ..., + ) -> None: ... + def open(self, filename: str) -> None: ... + def close(self) -> None: ... + def warn( + self, msg: str, line: list[int] | tuple[int, int] | int | None = None + ) -> None: ... + def readline(self) -> str | None: ... + def readlines(self) -> list[str]: ... + def unreadline(self, line: str) -> str: ... diff --git a/typings/distutils-stubs/unixccompiler.pyi b/typings/distutils-stubs/unixccompiler.pyi new file mode 100644 index 0000000000..0a3ec2321c --- /dev/null +++ b/typings/distutils-stubs/unixccompiler.pyi @@ -0,0 +1,3 @@ +from .ccompiler import CCompiler + +class UnixCCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/util.pyi b/typings/distutils-stubs/util.pyi new file mode 100644 index 0000000000..b750dfaad0 --- /dev/null +++ b/typings/distutils-stubs/util.pyi @@ -0,0 +1,38 @@ +from collections.abc import Callable, Mapping + +from _typeshed import Unused +from typing_extensions import TypeVarTuple, Unpack + +_Ts = TypeVarTuple("_Ts") + +def get_host_platform() -> str: ... +def get_platform() -> str: ... +def get_macosx_target_ver_from_syscfg(): ... +def get_macosx_target_ver(): ... +def split_version(s: str) -> list[int]: ... +def convert_path(pathname: str) -> str: ... +def change_root(new_root: str, pathname: str) -> str: ... +def check_environ() -> None: ... +def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... +def grok_environment_error(exc: object, prefix: str = "error: ") -> str: ... +def split_quoted(s: str) -> list[str]: ... +def execute( + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + verbose: bool = False, + dry_run: bool = False, +) -> None: ... +def strtobool(val: str) -> bool: ... +def byte_compile( + py_files: list[str], + optimize: int = 0, + force: bool = False, + prefix: str | None = None, + base_dir: str | None = None, + verbose: bool = True, + dry_run: bool = False, + direct: bool | None = None, +) -> None: ... +def rfc822_escape(header: str) -> str: ... +def is_mingw() -> bool: ... diff --git a/typings/distutils-stubs/version.pyi b/typings/distutils-stubs/version.pyi new file mode 100644 index 0000000000..b0cee01b15 --- /dev/null +++ b/typings/distutils-stubs/version.pyi @@ -0,0 +1,37 @@ +from abc import abstractmethod +from re import Pattern + +from typing_extensions import Self + +class Version: + def __eq__(self, other: object) -> bool: ... + def __lt__(self, other: Self | str) -> bool: ... + def __le__(self, other: Self | str) -> bool: ... + def __gt__(self, other: Self | str) -> bool: ... + def __ge__(self, other: Self | str) -> bool: ... + @abstractmethod + def __init__(self, vstring: str | None = None) -> None: ... + @abstractmethod + def parse(self, vstring: str) -> Self: ... + @abstractmethod + def __str__(self) -> str: ... + @abstractmethod + def _cmp(self, other: Self | str) -> bool: ... + +class StrictVersion(Version): + version_re: Pattern[str] + version: tuple[int, int, int] + prerelease: tuple[str, int] | None + def __init__(self, vstring: str | None = None) -> None: ... + def parse(self, vstring: str) -> Self: ... + def __str__(self) -> str: ... # noqa: PYI029 + def _cmp(self, other: Self | str) -> bool: ... + +class LooseVersion(Version): + component_re: Pattern[str] + vstring: str + version: tuple[str | int, ...] + def __init__(self, vstring: str | None = None) -> None: ... + def parse(self, vstring: str) -> Self: ... + def __str__(self) -> str: ... # noqa: PYI029 + def _cmp(self, other: Self | str) -> bool: ...