classification
Title: Fix compiler detection when brew's ccache is installed on Mac OS X
Type: Stage: resolved
Components: Distutils Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ned.deily Nosy List: dstufft, eric.araujo, jszakmeister, ned.deily, python-dev
Priority: normal Keywords: patch

Created on 2014-04-19 13:21 by jszakmeister, last changed 2014-04-19 22:27 by jszakmeister. This issue is now closed.

Files
File name Uploaded Description Edit
fix-osx-llvm-detection-with-ccache.patch jszakmeister, 2014-04-19 13:21 First fix: non-empty check before examining output. review
alt-fix-osx-llvm-detection-with-ccache.patch jszakmeister, 2014-04-19 13:21 Alternate fix: return empty string from _read_output review
Messages (5)
msg216856 - (view) Author: John Szakmeister (jszakmeister) * Date: 2014-04-19 13:21
It's pretty typical for ccache packages to install symlinks for compilers that may not be present on the system, such as Homebrew's ccache package.  Unfortunately, the _osx_support.py file is mislead by the presence of the symlink and ends up backtracing.

This issue is present in 2.7 and onwards.  I'm attaching two possible fixes for the problem, both created against 2.7.  The issue is that the symlink in detected, but _read_output() returns None, which then fails when the output is examined (if 'str' in None...).  The first patch does a simple non-empty check.  The alternate version makes _read_output() return an empty string instead of None.
msg216857 - (view) Author: John Szakmeister (jszakmeister) * Date: 2014-04-19 13:21
Here's the alternate fix.
msg216877 - (view) Author: Roundup Robot (python-dev) Date: 2014-04-19 20:27
New changeset e3217efa6edd by Ned Deily in branch '2.7':
Issue #21311: Avoid exception in _osx_support with non-standard compiler
http://hg.python.org/cpython/rev/e3217efa6edd

New changeset 3d1578c705c9 by Ned Deily in branch '3.4':
Issue #21311: Avoid exception in _osx_support with non-standard compiler
http://hg.python.org/cpython/rev/3d1578c705c9

New changeset 2a4401109672 by Ned Deily in branch 'default':
Issue #21311: merge with 3.4
http://hg.python.org/cpython/rev/2a4401109672
msg216878 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-04-19 20:35
Thanks for the report and the patches.  I am not sure exactly what problem using ccache is causing but it is clear that, if for whatever reason the call to _read_output fails and returns None, the 'llvm-gcc' test will fail so that test should be fixed as suggested in your first patch which I've applied for release in 2.7.7, 3.4.1, and 3.5.0.
msg216884 - (view) Author: John Szakmeister (jszakmeister) * Date: 2014-04-19 22:27
Thank you Ned!  The issue is that you can create symlinks to ccache to and put them on your path.  Distros do this for you now, but most create symlinks for a bunch of compilers... including ones that may not be installed.  So the presence of the name ('gcc', for instance) doesn't mean that the compiler is actually installed.  It could be a symlink to the ccache binary and running it could fail.  I hope that makes a little more sense.

Thanks again for applying the patch!
History
Date User Action Args
2014-04-19 22:27:12jszakmeistersetmessages: + msg216884
2014-04-19 20:35:17ned.deilysetstatus: open -> closed
versions: - Python 3.1, Python 3.2, Python 3.3
messages: + msg216878

resolution: fixed
stage: resolved
2014-04-19 20:27:46python-devsetnosy: + python-dev
messages: + msg216877
2014-04-19 19:02:14ned.deilysetassignee: ned.deily

nosy: + ned.deily
2014-04-19 13:21:40jszakmeistersetfiles: + alt-fix-osx-llvm-detection-with-ccache.patch

messages: + msg216857
2014-04-19 13:21:02jszakmeistercreate