python314Packages.dlib: fix build after dlib 20.0.1 bump (#554373)

This commit is contained in:
Sandro
2026-08-21 02:51:34 +00:00
committed by GitHub
3 changed files with 19 additions and 17 deletions

View File

@@ -17,6 +17,7 @@
avxSupport ? stdenv.hostPlatform.avxSupport,
cudaSupport ? config.cudaSupport,
cudaPackages,
python3Packages,
}@inputs:
(if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv).mkDerivation rec {
pname = "dlib";
@@ -81,6 +82,9 @@
);
passthru = {
tests = {
python-dlib = python3Packages.dlib;
};
inherit
cudaSupport
cudaPackages

View File

@@ -1,8 +1,8 @@
diff --git a/setup.py b/setup.py
index 219583b..3ca5f88 100644
index 59b65a62..363c9e56 100644
--- a/setup.py
+++ b/setup.py
@@ -170,23 +170,7 @@ class CMakeBuild(build_ext):
@@ -217,23 +217,7 @@ def build_extension(self, ext):
subprocess.check_call(cmake_build, cwd=build_folder)
def num_available_cpu_cores(ram_per_build_process_in_gb):
@@ -13,9 +13,9 @@ index 219583b..3ca5f88 100644
- elif 'CMAKE_BUILD_PARALLEL_LEVEL' in os.environ and os.environ['CMAKE_BUILD_PARALLEL_LEVEL'].isnumeric():
- return int(os.environ['CMAKE_BUILD_PARALLEL_LEVEL'])
- try:
- mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
- mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
- mem_gib = mem_bytes/(1024.**3)
- num_cores = multiprocessing.cpu_count()
- num_cores = multiprocessing.cpu_count()
- # make sure we have enough ram for each build process.
- mem_cores = int(floor(mem_gib/float(ram_per_build_process_in_gb)+0.5));
- # We are limited either by RAM or CPU cores. So pick the limiting amount
@@ -26,4 +26,4 @@ index 219583b..3ca5f88 100644
+ return os.getenv("NIX_BUILD_CORES", 1)
from setuptools.command.test import test as TestCommand
def read_version_from_cmakelists(cmake_file):

View File

@@ -1,8 +1,9 @@
{
buildPythonPackage,
cmake,
dlib,
pytestCheckHook,
more-itertools,
setuptools,
}:
buildPythonPackage.override { inherit (dlib) stdenv; } {
@@ -17,21 +18,14 @@ buildPythonPackage.override { inherit (dlib) stdenv; } {
meta
;
format = "setuptools";
patches = [ ./build-cores.patch ];
nativeCheckInputs = [
pytestCheckHook
more-itertools
pyproject = true;
build-system = [
cmake
setuptools
];
postPatch = ''
substituteInPlace setup.py \
--replace "more-itertools<6.0.0" "more-itertools" \
--replace "pytest==3.8" "pytest"
'';
# Pass CMake flags through to the build script
preConfigure = ''
for flag in $cmakeFlags; do
@@ -43,6 +37,10 @@ buildPythonPackage.override { inherit (dlib) stdenv; } {
dontUseCmakeConfigure = true;
nativeCheckInputs = [
pytestCheckHook
];
doCheck =
!(
# The tests attempt to use CUDA on the build platform.