set-xcode-analyzer requires Python 2.7.0+

Hello,

I was just trying out clang's static analyzer and, following the instructions at
<http://clang-analyzer.llvm.org/xcode.html&gt;, set XCode's analyzer to my build of
clang TOT using the following command line (in myLLVM/llvm/tools/clang/tools/scan-build)

./set-xcode-analyzer --use-checker-build=myLLVM/build/Release+Asserts/bin/clang

This resulted in the following error:

(+) Using Clang located at: myLLVM/build/Release+Asserts/bin/clang
Traceback (most recent call last):
  File "./set-xcode-analyzer", line 88, in <module>
    main()
  File "./set-xcode-analyzer", line 78, in main
    xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
AttributeError: 'module' object has no attribute 'check_output'

This is because OS X 10.6.8 (which I'm running) only has Python 2.6.1 installed, but
"check_output" was introduced in 2.7.0 (<http://docs.python.org/library/subprocess.html&gt;\).

The change to set-xcode-analyzer was made with r151179 to make the script work with
XCode 4.3 (which I assume can be installed in a different location than /Developer).

Of course it's no problem to locally undo this change; I am just wondering if the above
is the indented behavior on Snow Leopard.

Jonathan

Hi Jonathan,

I've heard about a related issue with Python version compatibility:

  Bug 11661 - set-xcode-analyzer fails if Python 2.7 is installed
  http://llvm.org/bugs/show_bug.cgi?id=11661

That seems like a different issue, that I haven't been able to reproduce.

I think the bottom line is that I'd like set-xcode-analyzer to work regardless of your Python configuration, at least back to Snow Leopard (which supported Xcode 4.0). I'm not a Python expert, this would also be easy to implement in straight C code, and remove the dependency on Python entirely.

Can you file a bug report?

Thanks,
Ted

Hello Ted,

I think the bottom line is that I'd like set-xcode-analyzer to work regardless of your Python configuration, at least back to Snow Leopard (which supported Xcode 4.0). I'm not a Python expert, this would also be easy to implement in straight C code, and remove the dependency on Python entirely.

I would think Python to be easier to use than C, honestly. The script mostly changes a few text
files, and string handling is IMO vastly superior in Python than in C. As every Mac OS X has one
version or the other of Python installed, a general dependency on it does not seem to be a
problem to me.

Can you file a bug report?

<13345 – set-xcode-analyzer does not work in Snow Leopard: Python is too old; (filed yesterday, so this mail is more for the
record). I included a patch as well to keep you away from porting the script to C :wink:

Jonathan

Thanks! I've committed the fix you provided in r160321.