diff --git a/jobs/JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP b/jobs/JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP index 2e49a9f14d..bad646bf2d 100755 --- a/jobs/JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP +++ b/jobs/JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP @@ -34,7 +34,8 @@ RUN=${GDUMP} YMD=${gPDY} HH=${gcyc} generate_com -rx \ # Add UFSDA to PYTHONPATH ufsdaPATH="${HOMEgfs}/sorc/gdas.cd/ush/" -pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python3.7/" +# shellcheck disable=SC2311 +pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python$(detect_py_ver)/" PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${ufsdaPATH}:${pyiodaPATH}" export PYTHONPATH diff --git a/jobs/rocoto/prepatmiodaobs.sh b/jobs/rocoto/prepatmiodaobs.sh index d424df9261..0e69eda5c9 100755 --- a/jobs/rocoto/prepatmiodaobs.sh +++ b/jobs/rocoto/prepatmiodaobs.sh @@ -14,8 +14,9 @@ export jobid="${job}.$$" ############################################################### # setup python path for workflow and ioda utilities wxflowPATH="${HOMEgfs}/ush/python:${HOMEgfs}/ush/python/wxflow/src" -PYIODALIB="${HOMEgfs}/sorc/gdas.cd/build/lib/python3.7" -PYTHONPATH="${PYIODALIB}:${wxflowPATH}:${PYTHONPATH}" +# shellcheck disable=SC2311 +pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python$(detect_py_ver)/" +PYTHONPATH="${pyiodaPATH}:${wxflowPATH}:${PYTHONPATH}" export PYTHONPATH ############################################################### diff --git a/jobs/rocoto/prepsnowobs.sh b/jobs/rocoto/prepsnowobs.sh index dae11129eb..cff082bab2 100755 --- a/jobs/rocoto/prepsnowobs.sh +++ b/jobs/rocoto/prepsnowobs.sh @@ -14,7 +14,9 @@ export jobid="${job}.$$" ############################################################### # setup python path for workflow utilities and tasks wxflowPATH="${HOMEgfs}/ush/python:${HOMEgfs}/ush/python/wxflow/src" -gdasappPATH="${HOMEgfs}/sorc/gdas.cd/iodaconv/src:${HOMEgfs}/sorc/gdas.cd/build/lib/python3.7" +# shellcheck disable=SC2311 +pyiodaPATH="${HOMEgfs}/sorc/gdas.cd/build/lib/python$(detect_py_ver)/" +gdasappPATH="${HOMEgfs}/sorc/gdas.cd/sorc/iodaconv/src:${pyiodaPATH}" PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${wxflowPATH}:${gdasappPATH}" export PYTHONPATH diff --git a/ush/preamble.sh b/ush/preamble.sh index d10d7541c8..35f32d10bc 100644 --- a/ush/preamble.sh +++ b/ush/preamble.sh @@ -172,6 +172,22 @@ function generate_com() { # shellcheck disable= declare -xf generate_com +function detect_py_ver() { + # + # Returns the major.minor version of the currently active python executable + # + regex="[0-9]+\.[0-9]+" + # shellcheck disable=SC2312 + if [[ $(python --version) =~ ${regex} ]]; then + echo "${BASH_REMATCH[0]}" + else + echo "FATAL ERROR: Could not detect the python version" + exit 1 + fi +} +# shellcheck disable= +declare -xf detect_py + # Turn on our settings set_strict set_trace