From 9439179a0a1863aba5ff4c8b4b5dea8ec3940c8d Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 2 Oct 2019 18:11:35 +0300 Subject: [PATCH] Reinstate and simplify parallel auto-detection --- setup.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/setup.py b/setup.py index c3e0dfc9fe1..c72e029665e 100755 --- a/setup.py +++ b/setup.py @@ -326,6 +326,15 @@ def finalize_options(self): if self.debug: global DEBUG DEBUG = True + if not self.parallel: + # If --parallel (or -j) wasn't specified, we want to reproduce the same + # behavior as before, that is, auto-detect the number of jobs. + try: + self.parallel = int( + os.environ.get("MAX_CONCURRENCY", min(4, os.cpu_count())) + ) + except TypeError: + self.parallel = None for x in self.feature: if getattr(self, "disable_%s" % x): setattr(self.feature, x, False)