How can I check that clang is built or that clang tool is available?
I need to check it in Python 2.7.
I tried with os.path.exists(file_path), but you can build clang anywhere so it is not the best way.
How can I check that clang is built or that clang tool is available?
I need to check it in Python 2.7.
I tried with os.path.exists(file_path), but you can build clang anywhere so it is not the best way.
This might work for you if clang is available in the path, it performs a search for the presence of the clang executable:
from distutils.spawn import find_executable
clang_executable = find_executable('clang')
If it finds clang it will return the path to the executable, e.g. /usr/bin/clang, otherwise it will return None.
This is the relevant part of the docs (not that descriptive), and here is a SO question looking for something similar.
You could install gnu which: http://gnuwin32.sourceforge.net/packages/which.htm
Add which to your PATH, and then run:
import subprocess
subprocess.check_output("which clang")
If you're using Unix/Linux and clang is on your PATH:
import subprocess
c = subprocess.call(["which", "clang"])
if c == 0:
print("clang is available")