Commits

Ned Batchelder  committed 740b68e

setup.py now succeeds even if there is no C compiler. Fixes issue #80.

  • Participants
  • Parent commits c7506f5

Comments (0)

Files changed (2)

   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
 """
 
 # 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
     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 = [
         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)