MINGW-packages/mingw-w64-dlib/001-python-binding.patch
2025-03-04 06:19:41 +00:00

53 lines
1.9 KiB
Diff

--- a/dlib/external/pybind11/tools/FindPythonLibsNew.cmake
+++ b/dlib/external/pybind11/tools/FindPythonLibsNew.cmake
@@ -233,7 +233,7 @@
if(DEFINED PYTHON_LIBRARY)
# Don't write to PYTHON_LIBRARY if it's already set
-elseif(CMAKE_HOST_WIN32)
+elseif(CMAKE_HOST_WIN32 AND NOT MINGW)
set(PYTHON_LIBRARY "${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
# when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the
--- a/tools/python/CMakeLists.txt
+++ b/tools/python/CMakeLists.txt
@@ -1,7 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0)
-if (WIN32 AND NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+if (MSVC AND NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
message(FATAL_ERROR "\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"You must use Visual Studio to build a python extension on windows. If you "
--- a/setup.py
+++ b/setup.py
@@ -34,6 +34,7 @@
import sys
import shutil
import platform
+import sysconfig
import subprocess
import multiprocessing
from distutils import log
@@ -144,7 +145,7 @@
cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
- if platform.system() == "Windows":
+ if platform.system() == "Windows" and not sysconfig.get_platform().startswith('mingw'):
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
@@ -187,8 +188,8 @@
# We are limited either by RAM or CPU cores. So pick the limiting amount
# and return that.
return max(min(num_cores, mem_cores), 1)
- except ValueError:
+ except:
- return 2 # just assume 2 if we can't get the os to tell us the right answer.
+ return 3 # just assume 3 if we can't get the os to tell us the right answer.
from setuptools.command.test import test as TestCommand