[Shell] Simplify Extracting Python Version
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 18 Apr 2019 01:37:19 +0000 (01:37 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 18 Apr 2019 01:37:19 +0000 (01:37 +0000)
Instead of parsing the Python version with a fairly convoluted regex,
just print the major and minor version and call it a day.

llvm-svn: 358635

lldb/scripts/Python/finish-swig-Python-LLDB.sh

index 31bc2b3..1cd1774 100755 (executable)
@@ -56,8 +56,7 @@ fi
 
 OS_NAME=`uname -s`
 PYTHON=${PYTHON_EXECUTABLE:-/usr/bin/env python}
-PYTHON_VERSION=`${PYTHON} --version 2>&1 | sed -e 's,Python ,,' -e 's,[.][0-9],,2' -e 's,[a-z][a-z][0-9],,'`
-
+PYTHON_VERSION=`${PYTHON} -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))'`
 
 if [ $Debug -eq 1 ]
 then