From 1ece6e6d1cdb9d1a3bae0429ab56b6c702039e4c Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 3 Jul 2023 12:11:49 -0700 Subject: [PATCH] Bring back a few setuptools._distutils files Linking #10255 There are cases of these being used, including in mypy This is reverts a small part of #9795 --- .../setuptools/_distutils/archive_util.pyi | 20 +++ .../setuptools/_distutils/ccompiler.pyi | 152 ++++++++++++++++++ .../setuptools/_distutils/dep_util.pyi | 3 + .../setuptools/_distutils/sysconfig.pyi | 14 ++ .../setuptools/setuptools/_distutils/util.pyi | 30 ++++ 5 files changed, 219 insertions(+) create mode 100644 stubs/setuptools/setuptools/_distutils/archive_util.pyi create mode 100644 stubs/setuptools/setuptools/_distutils/ccompiler.pyi create mode 100644 stubs/setuptools/setuptools/_distutils/dep_util.pyi create mode 100644 stubs/setuptools/setuptools/_distutils/sysconfig.pyi create mode 100644 stubs/setuptools/setuptools/_distutils/util.pyi diff --git a/stubs/setuptools/setuptools/_distutils/archive_util.pyi b/stubs/setuptools/setuptools/_distutils/archive_util.pyi new file mode 100644 index 000000000000..38458fc0e003 --- /dev/null +++ b/stubs/setuptools/setuptools/_distutils/archive_util.pyi @@ -0,0 +1,20 @@ +def make_archive( + base_name: str, + format: str, + root_dir: str | None = ..., + base_dir: str | None = ..., + verbose: int = ..., + dry_run: int = ..., + owner: str | None = ..., + group: str | None = ..., +) -> str: ... +def make_tarball( + base_name: str, + base_dir: str, + compress: str | None = ..., + verbose: int = ..., + dry_run: int = ..., + owner: str | None = ..., + group: str | None = ..., +) -> str: ... +def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ... diff --git a/stubs/setuptools/setuptools/_distutils/ccompiler.pyi b/stubs/setuptools/setuptools/_distutils/ccompiler.pyi new file mode 100644 index 000000000000..96a756bb2cf8 --- /dev/null +++ b/stubs/setuptools/setuptools/_distutils/ccompiler.pyi @@ -0,0 +1,152 @@ +from collections.abc import Callable +from typing import Any +from typing_extensions import TypeAlias + +_Macro: TypeAlias = tuple[str] | tuple[str, str | None] + +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 = ..., platform: str | None = ...) -> str: ... +def new_compiler( + plat: str | None = ..., compiler: str | None = ..., verbose: int = ..., dry_run: int = ..., force: int = ... +) -> CCompiler: ... +def show_compilers() -> None: ... + +class CCompiler: + 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: int = ..., dry_run: int = ..., force: int = ...) -> 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: ... + 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 = ...) -> str | None: ... + def has_function( + self, + funcname: str, + includes: list[str] | None = ..., + include_dirs: list[str] | None = ..., + libraries: list[str] | None = ..., + library_dirs: list[str] | 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 = ..., + macros: _Macro | None = ..., + include_dirs: list[str] | None = ..., + debug: bool = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + depends: list[str] | None = ..., + ) -> list[str]: ... + def create_static_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = ..., + debug: bool = ..., + target_lang: str | None = ..., + ) -> None: ... + def link( + self, + target_desc: str, + objects: list[str], + output_filename: str, + output_dir: str | None = ..., + libraries: list[str] | None = ..., + library_dirs: list[str] | None = ..., + runtime_library_dirs: list[str] | None = ..., + export_symbols: list[str] | None = ..., + debug: bool = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., + ) -> None: ... + def link_executable( + self, + objects: list[str], + output_progname: str, + output_dir: str | None = ..., + libraries: list[str] | None = ..., + library_dirs: list[str] | None = ..., + runtime_library_dirs: list[str] | None = ..., + debug: bool = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + target_lang: str | None = ..., + ) -> None: ... + def link_shared_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = ..., + libraries: list[str] | None = ..., + library_dirs: list[str] | None = ..., + runtime_library_dirs: list[str] | None = ..., + export_symbols: list[str] | None = ..., + debug: bool = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., + ) -> None: ... + def link_shared_object( + self, + objects: list[str], + output_filename: str, + output_dir: str | None = ..., + libraries: list[str] | None = ..., + library_dirs: list[str] | None = ..., + runtime_library_dirs: list[str] | None = ..., + export_symbols: list[str] | None = ..., + debug: bool = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., + ) -> None: ... + def preprocess( + self, + source: str, + output_file: str | None = ..., + macros: list[_Macro] | None = ..., + include_dirs: list[str] | None = ..., + extra_preargs: list[str] | None = ..., + extra_postargs: list[str] | None = ..., + ) -> None: ... + def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... + def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... + def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... + def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... + def execute(self, func: Callable[..., object], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... + def spawn(self, cmd: list[str]) -> None: ... + def mkpath(self, name: str, mode: int = ...) -> None: ... + def move_file(self, src: str, dst: str) -> str: ... + def announce(self, msg: str, level: int = ...) -> None: ... + def warn(self, msg: str) -> None: ... + def debug_print(self, msg: str) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/dep_util.pyi b/stubs/setuptools/setuptools/_distutils/dep_util.pyi new file mode 100644 index 000000000000..929d6ffd0c81 --- /dev/null +++ b/stubs/setuptools/setuptools/_distutils/dep_util.pyi @@ -0,0 +1,3 @@ +def newer(source: str, target: str) -> bool: ... +def newer_pairwise(sources: list[str], targets: list[str]) -> list[tuple[str, str]]: ... +def newer_group(sources: list[str], target: str, missing: str = ...) -> bool: ... diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi new file mode 100644 index 000000000000..c82da4323054 --- /dev/null +++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi @@ -0,0 +1,14 @@ +from collections.abc import Mapping + +from setuptools._distutils.ccompiler import CCompiler + +PREFIX: str +EXEC_PREFIX: str + +def get_config_var(name: str) -> int | str | None: ... +def get_config_vars(*args: str) -> Mapping[str, int | str]: ... +def get_config_h_filename() -> str: ... +def get_makefile_filename() -> str: ... +def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ... +def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = ...) -> str: ... +def customize_compiler(compiler: CCompiler) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/util.pyi b/stubs/setuptools/setuptools/_distutils/util.pyi new file mode 100644 index 000000000000..6790712ffe25 --- /dev/null +++ b/stubs/setuptools/setuptools/_distutils/util.pyi @@ -0,0 +1,30 @@ +from collections.abc import Callable, Mapping +from typing import Any +from typing_extensions import Literal + +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 = ...) -> str: ... +def split_quoted(s: str) -> list[str]: ... +def execute( + func: Callable[..., object], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... +) -> None: ... +def strtobool(val: str) -> Literal[0, 1]: ... +def byte_compile( + py_files: list[str], + optimize: int = ..., + force: bool = ..., + prefix: str | None = ..., + base_dir: str | None = ..., + verbose: bool = ..., + dry_run: bool = ..., + direct: bool | None = ..., +) -> None: ... +def rfc822_escape(header: str) -> str: ...