From a93e4271d8a11c1de7b819a3c1c71d307ed693f1 Mon Sep 17 00:00:00 2001 From: Michael Katz Date: Fri, 6 Feb 2026 22:25:02 -0500 Subject: [PATCH 1/2] copying dlls --- _custom_build.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/_custom_build.py b/_custom_build.py index d31bc2d..f6bb0b9 100644 --- a/_custom_build.py +++ b/_custom_build.py @@ -97,4 +97,47 @@ def build_cmake(self, ext): # Troubleshooting: if fail on line above then delete all possible # temporary CMake files including "CMakeCache.txt" in top level dir. os.chdir(str(cwd)) - shutil.copytree(build_temp / 'bin', Path(self.build_lib) / 'kstar_planner' / 'builds' / 'release' / 'bin', dirs_exist_ok=True) + + # Copy built binaries + bin_dest = Path(self.build_lib) / 'kstar_planner' / 'builds' / 'release' / 'bin' + shutil.copytree(build_temp / 'bin', bin_dest, dirs_exist_ok=True) + + # On Windows with MinGW, copy required runtime DLLs + if os.name == "nt": + self._copy_mingw_dlls(bin_dest) + + def _copy_mingw_dlls(self, bin_dest): + """Copy MinGW runtime DLLs to the bin directory on Windows.""" + import subprocess + + # Find the compiler executable + try: + result = subprocess.run(['where', 'g++'], capture_output=True, text=True, check=True) + gcc_path = Path(result.stdout.strip().split('\n')[0]) + mingw_bin = gcc_path.parent + + # List of required DLLs + required_dlls = [ + 'libstdc++-6.dll', + 'libgcc_s_seh-1.dll', + 'libgcc_s_dw2-1.dll', # 32-bit alternative + 'libwinpthread-1.dll' + ] + + copied_count = 0 + for dll_name in required_dlls: + dll_path = mingw_bin / dll_name + if dll_path.exists(): + dest_path = bin_dest / dll_name + shutil.copy2(dll_path, dest_path) + print(f"Copied {dll_name} to {dest_path}") + copied_count += 1 + + if copied_count > 0: + print(f"Successfully copied {copied_count} MinGW runtime DLL(s)") + else: + print("Warning: No MinGW DLLs found. If using MSVC, this is expected.") + + except (subprocess.CalledProcessError, FileNotFoundError, IndexError): + print("Warning: Could not locate MinGW compiler. Skipping DLL copy.") + print("If the executable fails to run, manually copy MinGW DLLs to the bin directory.") From 72906e2f63ca72d196b7081a2000aa7ff3d25b6c Mon Sep 17 00:00:00 2001 From: Michael Katz Date: Fri, 6 Feb 2026 22:36:16 -0500 Subject: [PATCH 2/2] elaborate print --- _custom_build.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/_custom_build.py b/_custom_build.py index f6bb0b9..49abf76 100644 --- a/_custom_build.py +++ b/_custom_build.py @@ -107,21 +107,31 @@ def build_cmake(self, ext): self._copy_mingw_dlls(bin_dest) def _copy_mingw_dlls(self, bin_dest): - """Copy MinGW runtime DLLs to the bin directory on Windows.""" + """Copy MinGW runtime DLLs to the bin directory on Windows. + + On Windows, there are two scenarios: + 1. MSVC: Uses static linking (/MT flag), no DLLs needed (like macOS system libs) + 2. MinGW/GCC: Requires runtime DLLs (unlike macOS where system libs are always available) + """ import subprocess - # Find the compiler executable + print("Checking for Windows runtime dependencies...") + + # Check if we're using MinGW/GCC try: result = subprocess.run(['where', 'g++'], capture_output=True, text=True, check=True) gcc_path = Path(result.stdout.strip().split('\n')[0]) mingw_bin = gcc_path.parent + print(f"Found MinGW compiler at: {gcc_path}") - # List of required DLLs + # List of required DLLs for MinGW + # These are the Windows equivalent of macOS's libc++.1.dylib and libSystem.B.dylib + # but unlike macOS, these are NOT part of the base Windows system required_dlls = [ - 'libstdc++-6.dll', - 'libgcc_s_seh-1.dll', - 'libgcc_s_dw2-1.dll', # 32-bit alternative - 'libwinpthread-1.dll' + 'libstdc++-6.dll', # C++ standard library (like libc++.1.dylib on macOS) + 'libgcc_s_seh-1.dll', # GCC runtime for 64-bit + 'libgcc_s_dw2-1.dll', # GCC runtime for 32-bit + 'libwinpthread-1.dll' # POSIX threads (Windows doesn't have native pthreads) ] copied_count = 0 @@ -130,14 +140,15 @@ def _copy_mingw_dlls(self, bin_dest): if dll_path.exists(): dest_path = bin_dest / dll_name shutil.copy2(dll_path, dest_path) - print(f"Copied {dll_name} to {dest_path}") + print(f" Copied {dll_name}") copied_count += 1 if copied_count > 0: - print(f"Successfully copied {copied_count} MinGW runtime DLL(s)") + print(f"Successfully bundled {copied_count} MinGW runtime DLL(s) for distribution") else: - print("Warning: No MinGW DLLs found. If using MSVC, this is expected.") + print("Warning: No MinGW DLLs found in compiler directory.") except (subprocess.CalledProcessError, FileNotFoundError, IndexError): - print("Warning: Could not locate MinGW compiler. Skipping DLL copy.") - print("If the executable fails to run, manually copy MinGW DLLs to the bin directory.") + print("MinGW/GCC not found - assuming MSVC build with static linking.") + print("MSVC builds use /MT flag for static C++ runtime (no DLLs needed).") + print("This is similar to how macOS system libraries work.")