From eca7ecb1662390ba681a630fdd80244434059b38 Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Mon, 2 Jan 2023 14:10:59 +0100 Subject: [PATCH] spns #32335: some projects still rely on Python 2. Implement a switch based on Python major version number --- products/compil_scripts/omniORB.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/products/compil_scripts/omniORB.sh b/products/compil_scripts/omniORB.sh index abd2a8e..475fd5c 100755 --- a/products/compil_scripts/omniORB.sh +++ b/products/compil_scripts/omniORB.sh @@ -42,10 +42,17 @@ if version_ge $VERSION "4.1" ; then echo echo "*** fix headers" cd $PRODUCT_INSTALL/bin - sed -e "s%#\!.*python[0-9]*%#\!/usr/bin/env python3%" omniidl > _omniidl + + pyVersionMajor=python$($PYTHONBIN -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))') + if [ $? -ne 0 ]; then + echo ERROR: Failed to extract major Python version - assuming Python version equal to 3... + pyVersionMajor=python3 + fi + echo INFO: Python version major: ${pyVersionMajor} + sed -e "s%#\!.*python[0-9]*%#\!/usr/bin/env ${pyVersionMajor}%" omniidl > _omniidl mv -f _omniidl omniidl chmod a+x omniidl - sed -e "s%#\!.*python[0-9]*%#\!/usr/bin/env python3%" omniidlrun.py > _omniidlrun.py + sed -e "s%#\!.*python[0-9]*%#\!/usr/bin/env ${pyVersionMajor}%" omniidlrun.py > _omniidlrun.py mv -f _omniidlrun.py omniidlrun.py chmod a+x omniidlrun.py fi -- 2.39.2