Skip to content

Commit

Permalink
Fall back to pure-python mode on any exception during the build.
Browse files Browse the repository at this point in the history
Stop the futile process of trying to enumerate which kinds of exceptions
distutils may throw (the latest potential addition: ValueError).

Closes #1115.
  • Loading branch information
bdarnell committed Jul 17, 2014
1 parent 52b6d1d commit 58370bd
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@
# to support installing without the extension on platforms where
# no compiler is available.
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError
from distutils.errors import DistutilsPlatformError, DistutilsExecError
if sys.platform == 'win32' and sys.version_info > (2, 6):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
build_errors = (CCompilerError, DistutilsExecError,
DistutilsPlatformError, IOError)
else:
build_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
SystemError)

class custom_build_ext(build_ext):
"""Allow C extension building to fail.
Expand Down Expand Up @@ -83,7 +73,7 @@ class custom_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)
except build_errors:
except Exception:
e = sys.exc_info()[1]
sys.stdout.write('%s\n' % str(e))
warnings.warn(self.warning_message % ("Extension modules",
Expand All @@ -95,7 +85,7 @@ def build_extension(self, ext):
name = ext.name
try:
build_ext.build_extension(self, ext)
except build_errors:
except Exception:
e = sys.exc_info()[1]
sys.stdout.write('%s\n' % str(e))
warnings.warn(self.warning_message % ("The %s extension "
Expand Down

0 comments on commit 58370bd

Please sign in to comment.