summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-06-11 07:54:23 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-06-11 07:54:23 -0400
commitc7d1c79367fa22c88a932d6a5e88095b74092fcf (patch)
treeb8e6b82592d61291361dae77c0ab69a964cd0c4e /setup.py
parent65ae23a8fe1b8e5740431497331fecfbd3c8b3fd (diff)
downloadpython-coveragepy-git-c7d1c79367fa22c88a932d6a5e88095b74092fcf.tar.gz
Clean up the setup.py hack to detect not being able to build the C extension. Fixes #183.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/setup.py b/setup.py
index 5d6c4d76..39756796 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ Topic :: Software Development :: Testing
"""
# Pull in the tools we need.
-import sys, traceback
+import sys
# Distribute is a new fork of setuptools. It's supported on Py3.x, so we use
# it there, but stick with classic setuptools on Py2.x until Distribute becomes
@@ -131,10 +131,15 @@ if sys.version_info >= (3, 0):
try:
setup(**setup_args)
except: # pylint: disable=W0702
- if 'ext_modules' not in setup_args:
+ # When setup() can't compile, it tries to exit. We'll catch SystemExit
+ # here :-(, and try again.
+ if 'install' not in sys.argv or 'ext_modules' not in setup_args:
+ # We weren't trying to install an extension, so forget it.
raise
msg = "Couldn't install with extension module, trying without it..."
- exc_msg = traceback.format_exc(0).split('\n')[-2]
+ exc = sys.exc_info()[1]
+ exc_msg = "%s: %s" % (exc.__class__.__name__, exc)
print("**\n** %s\n** %s\n**" % (msg, exc_msg))
+
del setup_args['ext_modules']
setup(**setup_args)