summaryrefslogtreecommitdiff
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
parent7c9a0eca3d61506825c03dae260a683a00d27fbb (diff)
downloadpython-coveragepy-git-2748b0dc7ec5fe7dbfb8c1ab6677c7c17999b25b.tar.gz
setup.py now succeeds even if there is no C compiler. Fixes issue #80.
-rw-r--r--CHANGES.txt4
-rw-r--r--setup.py17
2 files changed, 18 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index e8f463f9..e9d91286 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -26,9 +26,13 @@ Version 3.5
possible, to get the best handling of Python source files with encodings.
Closes `issue 107`, thanks, Brett Cannon.
+- Installation from source now succeeds on machines without a C compiler,
+ closing `issue 80`.
+
- Internally, files are now closed explicitly, fixing `issue 104`. Thanks,
Brett Cannon.
+.. _issue 80: https://bitbucket.org/ned/coveragepy/issue/80/is-there-a-duck-typing-way-to-know-we-cant
.. _issue 93: http://bitbucket.org/ned/coveragepy/issue/93/copying-a-mock-object-breaks-coverage
.. _issue 95: https://bitbucket.org/ned/coveragepy/issue/95/run-subcommand-should-take-a-module-name
.. _issue 104: https://bitbucket.org/ned/coveragepy/issue/104/explicitly-close-files
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)