Skip to content

Commit

Permalink
Patch distutils crash when linking with ccache
Browse files Browse the repository at this point in the history
  • Loading branch information
apaszke committed Jan 27, 2017
1 parent ce78bc8 commit 9c41151
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from setuptools import setup, Extension, distutils, Command, find_packages
import setuptools.command.build_ext
import setuptools.command.install
import distutils.unixccompiler
import distutils.command.build
import distutils.command.clean
import platform
Expand All @@ -17,6 +18,7 @@
################################################################################
# Monkey-patch setuptools to compile in parallel
################################################################################
original_link = distutils.unixccompiler.UnixCCompiler.link


def parallelCCompile(self, sources, output_dir=None, macros=None,
Expand All @@ -38,7 +40,17 @@ def _single_compile(obj):

return objects


def patched_link(self, *args, **kwargs):
_cxx = self.compiler_cxx
self.compiler_cxx = None
result = original_link(self, *args, **kwargs)
self.compiler_cxx = _cxx
return result


distutils.ccompiler.CCompiler.compile = parallelCCompile
distutils.unixccompiler.UnixCCompiler.link = patched_link

################################################################################
# Custom build commands
Expand Down

0 comments on commit 9c41151

Please sign in to comment.