summaryrefslogtreecommitdiff
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
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.
-rw-r--r--CHANGES.txt4
-rw-r--r--setup.py11
2 files changed, 12 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 404947f3..955e523f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,7 +8,11 @@ Version 3.5.3b1
- Files encoded as UTF-8 with a BOM are now properly handled, fixing
`issue 179`_. Thanks, Pablo Carballo.
+- Try to do a better job of the impossible task of detecting when we can't
+ build the C extension, fixing `issue 183`_.
+
.. _issue 179: https://bitbucket.org/ned/coveragepy/issue/179/htmlreporter-fails-when-source-file-is
+.. _issue 183: https://bitbucket.org/ned/coveragepy/issue/183/install-fails-for-python-23
Version 3.5.2 --- 4 May 2012
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)