From 88dd3e4dafdbfde55e11a71f408c6de7bbdd47d8 Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 16 Jan 2018 19:41:17 -0500 Subject: [PATCH] Set the number of cores to use for building based on system properties. --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 760bdfaea..b8435ff00 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,9 @@ import sys import shutil import platform import subprocess +import multiprocessing from distutils import log +from math import ceil from setuptools import setup, Extension from setuptools.command.build_ext import build_ext @@ -134,7 +136,9 @@ class CMakeBuild(build_ext): build_args += ['--', '/m'] else: cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] - build_args += ['--', '-j2'] + # Do a parallel build + num_cores = int(ceil(multiprocessing.cpu_count()/2.0)) + build_args += ['--', '-j'+str(num_cores)] build_folder = os.path.abspath(self.build_temp)