diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2012-06-11 07:54:23 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-06-11 07:54:23 -0400 |
| commit | b0d089c4df4b14e38c55016bcfa2d48d0e83c63d (patch) | |
| tree | 7aa52eaccab4d7b4da034e4e6782c8b1330b54f1 /setup.py | |
| parent | d31a41bfd035a537fd91e894805f411d17033847 (diff) | |
| download | python-coveragepy-b0d089c4df4b14e38c55016bcfa2d48d0e83c63d.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.py | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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) |
