Merge pull request #3272 from hsoft/parallel-builds

Fix builds with --parallel
This commit is contained in:
Hugo 2018-09-10 13:06:18 +03:00 committed by GitHub
commit a61cf12421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# A monkey patch of the base distutils.ccompiler to use parallel builds
# Tested on 2.7, looks to be identical to 3.3.
# Only applied on Python < 3.5 because otherwise, it conflicts with Python's
# own newly-added support for parallel builds.
from __future__ import print_function
from multiprocessing import Pool, cpu_count
@ -77,4 +79,6 @@ def install():
"%s processes" % MAX_PROCS)
# We monkeypatch only versions earlier than 3.5
if sys.version_info < (3, 5):
install()

View File

@ -205,6 +205,12 @@ class pil_build_ext(build_ext):
if self.debug:
global DEBUG
DEBUG = True
if sys.version_info >= (3, 5) and not self.parallel:
# For Python < 3.5, we monkeypatch distutils to have parallel
# builds. If --parallel (or -j) wasn't specified, we want to
# reproduce the same behavior as before, that is, auto-detect the
# number of jobs.
self.parallel = mp_compile.MAX_PROCS
for x in self.feature:
if getattr(self, 'disable_%s' % x):
setattr(self.feature, x, False)