Skip to content

Commit

Permalink
Merge pull request #2441 from Xarthisius/parallel_build
Browse files Browse the repository at this point in the history
[setup] return 0 as number of cpus on windows to disable parallel build
  • Loading branch information
matthewturk authored Feb 5, 2020
2 parents 2b07fbb + d65aa2f commit 1d1276d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import multiprocessing
import platform
from concurrent.futures import ThreadPoolExecutor as Pool
import glob
Expand All @@ -22,6 +21,8 @@
def _get_cpu_count():
if platform.system() != "Windows":
return os.cpu_count()
return 0


def _compile(
self, sources, output_dir=None, macros=None, include_dirs=None,
Expand Down Expand Up @@ -376,8 +377,9 @@ def finalize_options(self):
def build_extensions(self):
self.check_extensions_list(self.extensions)

if _get_cpu_count():
with Pool(_get_cpu_count()) as pool:
ncpus = _get_cpu_count()
if ncpus > 0:
with Pool(ncpus) as pool:
pool.map(self.build_extension, self.extensions)
else:
super().build_extensions()
Expand Down

0 comments on commit 1d1276d

Please sign in to comment.