summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-02-13 21:53:50 -0500
committerNed Batchelder <ned@nedbatchelder.com>2011-02-13 21:53:50 -0500
commit2748b0dc7ec5fe7dbfb8c1ab6677c7c17999b25b (patch)
treedca742982519abe84435473c458edba1ea04bbc4 /setup.py
parent7c9a0eca3d61506825c03dae260a683a00d27fbb (diff)
downloadpython-coveragepy-git-2748b0dc7ec5fe7dbfb8c1ab6677c7c17999b25b.tar.gz
setup.py now succeeds even if there is no C compiler. Fixes issue #80.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/setup.py b/setup.py
index f0e92685..5a39ad2c 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@ Topic :: Software Development :: Testing
"""
# Pull in the tools we need.
-import sys
+import sys, traceback
# 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
@@ -99,7 +99,7 @@ setup_args = dict(
url = __url__,
)
-# Is there a duck-typing way to know we can't compile extensions?
+# Jython can't compile C extensions
if not sys.platform.startswith('java'):
setup_args.update(dict(
ext_modules = [
@@ -112,4 +112,15 @@ if sys.version_info >= (3, 0):
use_2to3=False,
))
-setup(**setup_args)
+# For a variety of reasons, it might not be possible to install the C
+# extension. Try it with, and if it fails, try it without.
+try:
+ setup(**setup_args)
+except:
+ if 'ext_modules' not in setup_args:
+ raise
+ msg = "Couldn't install with extension module, trying without it..."
+ exc_msg = traceback.format_exc(0).split('\n')[-2]
+ print("**\n** %s\n** %s\n**" % (msg, exc_msg))
+ del setup_args['ext_modules']
+ setup(**setup_args)