@@ -502,14 +502,9 @@ main_checks() {
502502
503503 # deep checks for python, including fix
504504 # first we set the python interpreters to match PYTHON_TARGETS (and ensure the versions we set are actually built)
505- PYTHON2=$( emerge --info | grep -oE ' ^PYTHON_TARGETS=".*(python[23]_[0-9]\s*)+"' | grep -oE ' python2_[0-9]' | cut -d\" -f2 | cut -d" " -f 1 | sed ' s#_#.#' )
506505 # PYTHON_SINGLE_TARGET is the *main* python3 implementation
507- PYTHON3=$( emerge --info | grep -oE ' ^PYTHON_SINGLE_TARGET=".*(python3_[0-9]+\s*)+"' | grep -oE ' python3_[0-9]+' | cut -d\" -f2 | sed ' s#_#.#' )
508- if [ -z " ${PYTHON2} " ]; then
509- printf " Detected Python 2 is disabled\n"
510- printf " From PYTHON_TARGETS: %s\n" " $( emerge --info | grep ' ^PYTHON_TARGETS' ) "
511- printf " This is a good thing :-)\n"
512- fi
506+ PYTHON3=" $( portageq envvar PYTHON_SINGLE_TARGET | sed ' s#_#.#' ) "
507+ # PYTHON3="$(emerge --info | grep --color=never -oE '\bPYTHON_SINGLE_TARGET="[^"]+"' | grep --color=never -oE 'python3_[0-9]+' | sed 's#_#.#')"
513508 if [ -z " ${PYTHON3} " ]; then
514509 printf " Failed to autodetect PYTHON_TARGETS\n"
515510 printf " Detected Python 3: %s" " ${PYTHON3:- none} "
@@ -518,12 +513,17 @@ main_checks() {
518513 printf " This is fatal, python3 support is required, it is %s\n" " $( date +' %Y' ) "
519514 exit 1
520515 fi
521- " ${PYTHON3} " -c " from _multiprocessing import SemLock " || emerge -1 python: " ${PYTHON3 # python} "
522-
523- # fix python2, if it's even requested
524- if [ -n " ${PYTHON2 } " ] ; then
525- " ${PYTHON2} " -c " from _multiprocessing import SemLock " || emerge -1 python:" ${PYTHON2 # python} "
516+ if ! " ${PYTHON3} " --version ; then
517+ emerge -1 python: " ${PYTHON3 # python} "
518+ fi
519+ if ! " ${PYTHON3 } " -c " from _multiprocessing import SemLock " ; then
520+ emerge -1 python:" ${PYTHON3 # python} "
526521 fi
522+ if ! " ${PYTHON3} " --version || ! " ${PYTHON3} " -c " from _multiprocessing import SemLock" ; then
523+ printf ' The selected PYTHON_SINGLE_TARGET %s does not seem to be functional. Aborting for safety.\n' " ${PYTHON3} "
524+ exit 1
525+ fi
526+
527527
528528 # always update portage as early as we can (after making sure python works)
529529 emerge --update --newuse --oneshot --changed-deps --newrepo portage || safe_exit
0 commit comments