Reputation: 846
How can I find the version of clang installed on my system.
Link to clang lib: (click!)
I want functionality like:
if libclang.version < 3.4:
print('Clang version not supported.')
or some other logic so that I can find the version of clang.
There is no __version__
attribute in clang module. So I cannot do
if libclang.__version__ < 3.4
print('Clang version not supported.')
Upvotes: 2
Views: 5043
Reputation: 846
from pkg_resources import get_distribution
if get_distribution('libclang-py3').version != '3.4.0':
logging.error('clang version not supported')
get_distribution('pkg_name').version
will return the version of the installed package, but this might not work in all cases.
Upvotes: 3
Reputation: 129
If you're unable to get the version of any packages directly, you can execute
pip freeze | grep clang
in your script and in order to get execute this script, you can use subprocess module of python as mentioned below:
>>> import subprocess
>>> p = subprocess.Popen(["pip", "freeze", "|", "grep", "clang"], stdout=subprocess.PIPE)
>>> p.communicate()[0].splitlines()
this will return all packages installed along with their packages and there you can have clang version.
Upvotes: 1