From b777944557fea809524670ebd99c3034d8fad82b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 3 Sep 2024 13:29:49 +0200 Subject: [PATCH 01/10] [setuptools] Update to 74.1.* Closes: #12613 --- stubs/setuptools/METADATA.toml | 2 +- stubs/setuptools/setuptools/compat/py312.pyi | 3 + stubs/setuptools/setuptools/msvc.pyi | 176 +++++++++++++++++++ 3 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 stubs/setuptools/setuptools/compat/py312.pyi create mode 100644 stubs/setuptools/setuptools/msvc.pyi diff --git a/stubs/setuptools/METADATA.toml b/stubs/setuptools/METADATA.toml index 00c640ecdbd0..47969f29c563 100644 --- a/stubs/setuptools/METADATA.toml +++ b/stubs/setuptools/METADATA.toml @@ -1,4 +1,4 @@ -version = "74.0.*" +version = "74.1.*" upstream_repository = "https://github.com/pypa/setuptools" extra_description = """\ If using `setuptools >= 71.1` *only* for `pkg_resources`, diff --git a/stubs/setuptools/setuptools/compat/py312.pyi b/stubs/setuptools/setuptools/compat/py312.pyi new file mode 100644 index 000000000000..0b3a667177e4 --- /dev/null +++ b/stubs/setuptools/setuptools/compat/py312.pyi @@ -0,0 +1,3 @@ +from typing import Final + +PTH_ENCODING: Final[str | None] diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi new file mode 100644 index 000000000000..8b45f6ea9eea --- /dev/null +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -0,0 +1,176 @@ +from typing import ClassVar, Final, TypedDict, overload, type_check_only +from typing_extensions import LiteralString, NotRequired + +class winreg: + HKEY_USERS: Final[int | None] + HKEY_CURRENT_USER: Final[int | None] + HKEY_LOCAL_MACHINE: Final[int | None] + HKEY_CLASSES_ROOT: Final[int | None] + +environ: dict[str, str] + +class PlatformInfo: + current_cpu: ClassVar[str] + + arch: str + + def __init__(self, arch: str) -> None: ... + @property + def target_cpu(self) -> str: ... + def target_is_x86(self) -> bool: ... + def current_is_x86(self) -> bool: ... + def current_dir(self, hidex86: bool = False, x64: bool = False) -> str: ... + def target_dir(self, hidex86: bool = False, x64: bool = False) -> str: ... + def cross_dir(self, forcex86: bool = False) -> str: ... + +class RegistryInfo: + HKEYS: Final[tuple[int | None, ...]] + + pi: PlatformInfo + + def __init__(self, platform_info: PlatformInfo) -> None: ... + @property + def visualstudio(self) -> LiteralString: ... + @property + def sxs(self) -> LiteralString: ... + @property + def vc(self) -> LiteralString: ... + @property + def vs(self) -> LiteralString: ... + @property + def vc_for_python(self) -> LiteralString: ... + @property + def microsoft_sdk(self) -> LiteralString: ... + @property + def windows_sdk(self) -> LiteralString: ... + @property + def netfx_sdk(self) -> LiteralString: ... + @property + def windows_kits_roots(self) -> LiteralString: ... + @overload + def microsoft(self, key: LiteralString, x86: bool = False) -> LiteralString: ... + @overload + def microsoft(self, key: str, x86: bool = False) -> str: ... # type: ignore[misc] + def lookup(self, key: str, name: str) -> str: ... + +class SystemInfo: + WinDir: ClassVar[str] + ProgramFiles: ClassVar[str] + ProgramFilesx86 = ClassVar[str] + + ri: RegistryInfo + pi: PlatformInfo + known_vs_paths: dict[float, str] + vs_ver: float + vc_ver: float + + def __init__(self, registry_info: RegistryInfo, vc_ver: float | None = None) -> None: ... + def find_reg_vs_vers(self) -> list[float]: ... + def find_programdata_vs_vers(self) -> dict[float, str]: ... + @property + def VSInstallDir(self) -> str: ... + @property + def VCInstallDir(self) -> str: ... + @property + def WindowsSdkVersion(self) -> tuple[str, ...] | None: ... + @property + def WindowsSdkLastVersion(self) -> str: ... + @property + def WindowsSdkDir(self) -> str: ... + @property + def WindowsSDKExecutablePath(self) -> str | None: ... + @property + def FSharpInstallDir(self) -> str: ... + @property + def UniversalCRTSdkDir(self) -> str | None: ... + @property + def UniversalCRTSdkLastVersion(self) -> str: ... + @property + def NetFxSdkVersion(self) -> tuple[str, ...]: ... + @property + def NetFxSdkDir(self) -> str: ... + @property + def FrameworkDir32(self) -> str: ... + @property + def FrameworkDir64(self) -> str: ... + @property + def FrameworkVersion32(self) -> tuple[str, ...] | None: ... + @property + def FrameworkVersion64(self) -> tuple[str, ...] | None: ... + +@type_check_only +class _EnvironmentDict(TypedDict): + include: str + lib: str + libpath: str + path: str + py_vcruntime_redist: NotRequired[str | None] + +class EnvironmentInfo: + """ + Return environment variables for specified Microsoft Visual C++ version + and platform : Lib, Include, Path and libpath. + This function is compatible with Microsoft Visual C++ 9.0 to 14.X. + Script created by analysing Microsoft environment configuration files like + "vcvars[...].bat", "SetEnv.Cmd", "vcbuildtools.bat", ... + Parameters + ---------- + arch: str + Target architecture. + vc_ver: float + Required Microsoft Visual C++ version. If not set, autodetect the last + version. + vc_min_ver: float + Minimum Microsoft Visual C++ version. + """ + + pi: PlatformInfo + ri: RegistryInfo + si: SystemInfo + + def __init__(self, arch: str, vc_ver: float | None = None, vc_min_ver: float = 0) -> None: ... + @property + def vs_ver(self) -> float: ... + @property + def vc_ver(self) -> float: ... + @property + def VSTools(self) -> list[str]: ... + @property + def VCIncludes(self) -> list[str]: ... + @property + def VCLibraries(self) -> list[str]: ... + @property + def VCStoreRefs(self) -> list[str]: ... + @property + def VCTools(self) -> list[str]: ... + @property + def OSLibraries(self) -> list[str]: ... + @property + def OSIncludes(self) -> list[str]: ... + @property + def OSLibpath(self) -> list[str]: ... + @property + def SdkTools(self) -> list[str]: ... + @property + def SdkSetup(self) -> list[str]: ... + @property + def FxTools(self) -> list[str]: ... + @property + def NetFxSDKLibraries(self) -> list[str]: ... + @property + def NetFxSDKIncludes(self) -> list[str]: ... + @property + def VsTDb(self) -> list[str]: ... + @property + def MSBuild(self) -> list[str]: ... + @property + def HTMLHelpWorkshop(self) -> list[str]: ... + @property + def UCRTLibraries(self) -> list[str]: ... + @property + def UCRTIncludes(self) -> list[str]: ... + @property + def FSharp(self) -> list[str]: ... + @property + def VCRuntimeRedist(self) -> str | None: ... + def return_env(self, exists: bool = True) -> _EnvironmentDict: ... From 1be7da9781c8e31f2f804c41b54c16dcad73684f Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 3 Sep 2024 13:33:05 +0200 Subject: [PATCH 02/10] Fix type annotation --- stubs/setuptools/setuptools/msvc.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index 8b45f6ea9eea..aff0e045cbe1 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -56,7 +56,7 @@ class RegistryInfo: class SystemInfo: WinDir: ClassVar[str] ProgramFiles: ClassVar[str] - ProgramFilesx86 = ClassVar[str] + ProgramFilesx86: ClassVar[str] ri: RegistryInfo pi: PlatformInfo From e0053d7d5a4d14833d5f6af8433f8af63638e1b1 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 3 Sep 2024 13:44:40 +0200 Subject: [PATCH 03/10] stubtest fixes --- stubs/setuptools/@tests/stubtest_allowlist.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stubs/setuptools/@tests/stubtest_allowlist.txt b/stubs/setuptools/@tests/stubtest_allowlist.txt index a1b63cca526f..3e0b591bf38d 100644 --- a/stubs/setuptools/@tests/stubtest_allowlist.txt +++ b/stubs/setuptools/@tests/stubtest_allowlist.txt @@ -6,6 +6,13 @@ pkg_resources.ZipProvider.loader # @classmethod alias not handled correctly by stubtest pkg_resources.ZipManifests.load +# More precise type in typeshed (TypedDict vs os._Environ) +(setuptools.msvc.environ)? + +# At runtime, this is a module on Windows, while it's a class on other +# platforms and in typeshed +(setuptools.msvc.winreg)? + # Is a functools.partial, so stubtest says "is not a function" setuptools.modified.newer_pairwise_group setuptools._distutils._modified.newer_pairwise_group From 5783191eb8ff64ca3c2f20998f8cf2db5e9dc222 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 3 Sep 2024 13:48:57 +0200 Subject: [PATCH 04/10] Remove docstring --- stubs/setuptools/setuptools/msvc.pyi | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index aff0e045cbe1..9546031464d4 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -107,23 +107,6 @@ class _EnvironmentDict(TypedDict): py_vcruntime_redist: NotRequired[str | None] class EnvironmentInfo: - """ - Return environment variables for specified Microsoft Visual C++ version - and platform : Lib, Include, Path and libpath. - This function is compatible with Microsoft Visual C++ 9.0 to 14.X. - Script created by analysing Microsoft environment configuration files like - "vcvars[...].bat", "SetEnv.Cmd", "vcbuildtools.bat", ... - Parameters - ---------- - arch: str - Target architecture. - vc_ver: float - Required Microsoft Visual C++ version. If not set, autodetect the last - version. - vc_min_ver: float - Minimum Microsoft Visual C++ version. - """ - pi: PlatformInfo ri: RegistryInfo si: SystemInfo From 470dc87eadfd829e7c454a2b41d220a29b0275dd Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 4 Sep 2024 12:09:32 +0200 Subject: [PATCH 05/10] Use a few different annotations on Windows --- stubs/setuptools/setuptools/msvc.pyi | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index 9546031464d4..d4c627d3c526 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -1,11 +1,18 @@ +import sys from typing import ClassVar, Final, TypedDict, overload, type_check_only from typing_extensions import LiteralString, NotRequired class winreg: - HKEY_USERS: Final[int | None] - HKEY_CURRENT_USER: Final[int | None] - HKEY_LOCAL_MACHINE: Final[int | None] - HKEY_CLASSES_ROOT: Final[int | None] + if sys.platform == "win32": + HKEY_USERS: Final[int] + HKEY_CURRENT_USER: Final[int] + HKEY_LOCAL_MACHINE: Final[int] + HKEY_CLASSES_ROOT: Final[int] + else: + HKEY_USERS: Final[None] + HKEY_CURRENT_USER: Final[None] + HKEY_LOCAL_MACHINE: Final[None] + HKEY_CLASSES_ROOT: Final[None] environ: dict[str, str] @@ -24,7 +31,10 @@ class PlatformInfo: def cross_dir(self, forcex86: bool = False) -> str: ... class RegistryInfo: - HKEYS: Final[tuple[int | None, ...]] + if sys.platform == "win32": + HKEYS: Final[tuple[int, int, int, int]] + else: + HKEYS: Final[tuple[None, None, None, None]] pi: PlatformInfo From 05763bb26a4974207b4237b7fb659c9949539147 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 5 Sep 2024 15:36:59 +0200 Subject: [PATCH 06/10] Apply suggestions from code review Co-authored-by: Avasam --- stubs/setuptools/setuptools/msvc.pyi | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index d4c627d3c526..3279830db926 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -2,22 +2,20 @@ import sys from typing import ClassVar, Final, TypedDict, overload, type_check_only from typing_extensions import LiteralString, NotRequired -class winreg: - if sys.platform == "win32": - HKEY_USERS: Final[int] - HKEY_CURRENT_USER: Final[int] - HKEY_LOCAL_MACHINE: Final[int] - HKEY_CLASSES_ROOT: Final[int] - else: +if sys.platform == "win32": + import winreg as winreg + from os import environ as environ +else: + class winreg: HKEY_USERS: Final[None] HKEY_CURRENT_USER: Final[None] HKEY_LOCAL_MACHINE: Final[None] HKEY_CLASSES_ROOT: Final[None] -environ: dict[str, str] + environ: dict[str, str] class PlatformInfo: - current_cpu: ClassVar[str] + curren_cpu: Final[str] arch: str @@ -64,9 +62,9 @@ class RegistryInfo: def lookup(self, key: str, name: str) -> str: ... class SystemInfo: - WinDir: ClassVar[str] - ProgramFiles: ClassVar[str] - ProgramFilesx86: ClassVar[str] + WinDir: Final[str] + ProgramFiles: Final[str] + ProgramFilesx86: Final[str] ri: RegistryInfo pi: PlatformInfo From a7dc816ea79ae7a29267201227ca518780d1325b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 5 Sep 2024 15:37:31 +0200 Subject: [PATCH 07/10] Clean up allowlists --- stubs/setuptools/@tests/stubtest_allowlist.txt | 7 ------- stubs/setuptools/@tests/stubtest_allowlist_darwin.txt | 2 -- 2 files changed, 9 deletions(-) delete mode 100644 stubs/setuptools/@tests/stubtest_allowlist_darwin.txt diff --git a/stubs/setuptools/@tests/stubtest_allowlist.txt b/stubs/setuptools/@tests/stubtest_allowlist.txt index 3e0b591bf38d..a1b63cca526f 100644 --- a/stubs/setuptools/@tests/stubtest_allowlist.txt +++ b/stubs/setuptools/@tests/stubtest_allowlist.txt @@ -6,13 +6,6 @@ pkg_resources.ZipProvider.loader # @classmethod alias not handled correctly by stubtest pkg_resources.ZipManifests.load -# More precise type in typeshed (TypedDict vs os._Environ) -(setuptools.msvc.environ)? - -# At runtime, this is a module on Windows, while it's a class on other -# platforms and in typeshed -(setuptools.msvc.winreg)? - # Is a functools.partial, so stubtest says "is not a function" setuptools.modified.newer_pairwise_group setuptools._distutils._modified.newer_pairwise_group diff --git a/stubs/setuptools/@tests/stubtest_allowlist_darwin.txt b/stubs/setuptools/@tests/stubtest_allowlist_darwin.txt deleted file mode 100644 index 6b3c1d5e7f6c..000000000000 --- a/stubs/setuptools/@tests/stubtest_allowlist_darwin.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Mock -setuptools.msvc.winreg From 4a82322e82f602360ff6d350b54e9d4d66017fc8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:43:50 +0000 Subject: [PATCH 08/10] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/setuptools/msvc.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index 3279830db926..117af3c82c8d 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -3,7 +3,7 @@ from typing import ClassVar, Final, TypedDict, overload, type_check_only from typing_extensions import LiteralString, NotRequired if sys.platform == "win32": - import winreg as winreg + import winreg as winreg from os import environ as environ else: class winreg: From fb03572121d097363cf760c55ef730d89a505e6b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 5 Sep 2024 15:46:33 +0200 Subject: [PATCH 09/10] Fixes --- stubs/setuptools/setuptools/msvc.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index 117af3c82c8d..2b21443ec73e 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -1,5 +1,5 @@ import sys -from typing import ClassVar, Final, TypedDict, overload, type_check_only +from typing import Final, TypedDict, overload, type_check_only from typing_extensions import LiteralString, NotRequired if sys.platform == "win32": @@ -12,7 +12,7 @@ else: HKEY_LOCAL_MACHINE: Final[None] HKEY_CLASSES_ROOT: Final[None] - environ: dict[str, str] + environ: dict[str, str] class PlatformInfo: curren_cpu: Final[str] From bdcca7504073e9fee27fc2a8cbda3fcef8d00ffa Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 5 Sep 2024 15:53:46 +0200 Subject: [PATCH 10/10] Fix a typo --- stubs/setuptools/setuptools/msvc.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/msvc.pyi b/stubs/setuptools/setuptools/msvc.pyi index 2b21443ec73e..f07c4833d85f 100644 --- a/stubs/setuptools/setuptools/msvc.pyi +++ b/stubs/setuptools/setuptools/msvc.pyi @@ -15,7 +15,7 @@ else: environ: dict[str, str] class PlatformInfo: - curren_cpu: Final[str] + current_cpu: Final[str] arch: str