python312Packages.osmnx: 1.9.3 → 2.0.0 (#360529)
[NixPkgs.git] / pkgs / development / python-modules / dlib / build-cores.patch
blob072519975c433ab47b9b9a47a6f74a8fc073bc00
1 diff --git a/setup.py b/setup.py
2 index 219583b..3ca5f88 100644
3 --- a/setup.py
4 +++ b/setup.py
5 @@ -170,23 +170,7 @@ class CMakeBuild(build_ext):
6 subprocess.check_call(cmake_build, cwd=build_folder)
8 def num_available_cpu_cores(ram_per_build_process_in_gb):
9 - if 'TRAVIS' in os.environ and os.environ['TRAVIS']=='true':
10 - # When building on travis-ci, just use 2 cores since travis-ci limits
11 - # you to that regardless of what the hardware might suggest.
12 - return 2
13 - elif 'CMAKE_BUILD_PARALLEL_LEVEL' in os.environ and os.environ['CMAKE_BUILD_PARALLEL_LEVEL'].isnumeric():
14 - return int(os.environ['CMAKE_BUILD_PARALLEL_LEVEL'])
15 - try:
16 - mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
17 - mem_gib = mem_bytes/(1024.**3)
18 - num_cores = multiprocessing.cpu_count()
19 - # make sure we have enough ram for each build process.
20 - mem_cores = int(floor(mem_gib/float(ram_per_build_process_in_gb)+0.5));
21 - # We are limited either by RAM or CPU cores. So pick the limiting amount
22 - # and return that.
23 - return max(min(num_cores, mem_cores), 1)
24 - except ValueError:
25 - return 2 # just assume 2 if we can't get the os to tell us the right answer.
26 + return os.getenv("NIX_BUILD_CORES", 1)
29 from setuptools.command.test import test as TestCommand