From de2888d31d344c3d50994c4ecaaeb668bcc9b095 Mon Sep 17 00:00:00 2001 From: Marcelo Duarte Date: Thu, 25 Apr 2024 06:13:23 -0300 Subject: [PATCH] hooks: fix regression in msys2 (#2357) --- cx_Freeze/hooks/__init__.py | 20 ++++++++++---------- cx_Freeze/hooks/asyncio.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cx_Freeze/hooks/__init__.py b/cx_Freeze/hooks/__init__.py index a8795a6b2..dd26043cd 100644 --- a/cx_Freeze/hooks/__init__.py +++ b/cx_Freeze/hooks/__init__.py @@ -135,7 +135,7 @@ def load_cryptography(finder: ModuleFinder, module: Module) -> None: def load_ctypes(finder: ModuleFinder, module: Module) -> None: """The ctypes module should filter import names.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.add("nt") @@ -195,7 +195,7 @@ def load_dummy_threading(finder: ModuleFinder, module: Module) -> None: def load_encodings(finder: ModuleFinder, module: Module) -> None: """The encodings module should filter import names.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.add("_winapi") @@ -339,13 +339,13 @@ def load_markdown(finder: ModuleFinder, module: Module) -> None: def load_mimetypes(finder: ModuleFinder, module: Module) -> None: """The mimetypes module should filter import names.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.update(("_winapi", "winreg")) def load_ntpath(finder: ModuleFinder, module: Module) -> None: """The ntpath module should filter import names.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.update(("nt", "_winapi")) @@ -371,7 +371,7 @@ def load_os(finder: ModuleFinder, module: Module) -> None: """The os module should filter import names.""" if IS_WINDOWS: module.exclude_names.add("posix") - else: + elif not IS_MINGW: module.exclude_names.add("nt") @@ -379,7 +379,7 @@ def load_pathlib(finder: ModuleFinder, module: Module) -> None: """The pathlib module should filter import names.""" if IS_WINDOWS: module.exclude_names.update(("grp", "pwd")) - else: + elif not IS_MINGW: module.exclude_names.add("nt") @@ -408,7 +408,7 @@ def load_platform(finder: ModuleFinder, module: Module) -> None: module.exclude_names.add("vms_lib") if not IS_MACOS: module.exclude_names.add("plistlib") - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.add("winreg") module.exclude_names.add("_winreg") @@ -420,7 +420,7 @@ def load_plotly(finder: ModuleFinder, module: Module) -> None: def load_posixpath(finder: ModuleFinder, module: Module) -> None: """The posixpath module should filter import names.""" - if IS_WINDOWS: + if IS_WINDOWS and not IS_MINGW: module.exclude_names.add("posix") module.exclude_names.add("pwd") @@ -566,7 +566,7 @@ def load_shutil(finder: ModuleFinder, module: Module) -> None: """The shutil module should filter import names.""" if IS_WINDOWS: module.exclude_names.update(("grp", "posix", "pwd")) - else: + elif not IS_MINGW: module.exclude_names.update(("nt", "_winapi")) @@ -600,7 +600,7 @@ def load_subprocess(finder: ModuleFinder, module: Module) -> None: """The subprocess module should filter import names.""" if IS_WINDOWS: exclude_names = ("_posixsubprocess", "fcntl", "grp", "pwd") - else: + elif not IS_MINGW: exclude_names = ("msvcrt", "_winapi") module.exclude_names.update(exclude_names) diff --git a/cx_Freeze/hooks/asyncio.py b/cx_Freeze/hooks/asyncio.py index 1a902a1f9..085c129eb 100644 --- a/cx_Freeze/hooks/asyncio.py +++ b/cx_Freeze/hooks/asyncio.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING -from cx_Freeze._compat import IS_WINDOWS +from cx_Freeze._compat import IS_MINGW, IS_WINDOWS if TYPE_CHECKING: from cx_Freeze.finder import ModuleFinder @@ -20,11 +20,11 @@ def load_asyncio(finder: ModuleFinder, module: Module) -> None: # noqa: ARG001 def load_asyncio_windows_events(_, module: Module) -> None: """Ignore modules not found in current OS.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.update({"_overlapped", "_winapi", "msvcrt"}) def load_asyncio_windows_utils(_, module: Module) -> None: """Ignore modules not found in current OS.""" - if not IS_WINDOWS: + if not IS_WINDOWS and not IS_MINGW: module.exclude_names.update({"_winapi", "msvcrt"})