From 98a5591e12dee32a6453b1fc98dbec6db9fce314 Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Tue, 1 Apr 2025 11:21:33 -0400 Subject: [PATCH 1/4] Fix: Remove debug statements, change single bracket to double bracket --- pyperf/pyperf_run | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index ae8ce57..8228ac5 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -132,12 +132,23 @@ generate_csv_file() pip3_install() { - if [ $to_no_pkg_install -eq 0 ]; then - pip3 -q install $1 - if [ $? -ne 0 ]; then - exit_out "pip3 install of $1 failed." 1 + if [ $to_no_pkg_install -eq 1 ]; then + return + fi + + $python_exec -m pip --version + if [[ $? -ne 0 ]]; then + if [[ $install_pip -eq 1 ]]; then + $python_exec -m ensurepip || exit_out "Failed to install pip." 1 + else + exit_out "Pip is not available, exiting out" 1 fi fi + + $python_exec -m pip install -q $1 + if [[ $? -ne 0 ]]; then + exit_out "Pip not available for install of $1 failed." 1 + fi } # # Variables set by general setup. @@ -303,14 +314,13 @@ if [ $to_pbench -eq 0 ]; then mkdir python_results pyresults=python_results/pyperf_out_$(date "+%Y.%m.%d-%H.%M.%S") - pwd > /tmp/dave_debug - echo python3 -m pyperformance run --output ${pyresults}.json >> /tmp/dave_debug - python3 -m pyperformance run --output ${pyresults}.json + + $python_exec -m pyperformance run --output ${pyresults}.json if [ $? -ne 0 ]; then exit_out "Failed: python3 -m pyperformance run --output ${pyresults}.json" 1 fi - echo python3 -m pyperf dump ${pyresults}.json >> /tmp/dave_debug - python3 -m pyperf dump ${pyresults}.json > ${pyresults}.results + + $python_exec -m pyperf dump ${pyresults}.json > ${pyresults}.results if [ $? -ne 0 ]; then echo "Failed: python3 -m pyperf dump ${pyresults}.json > ${pyresults}.results" 1 echo Failed > test_results_report From 1ed8c14cf0e856d765e255754ccb828129c4246a Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Tue, 1 Apr 2025 12:00:40 -0400 Subject: [PATCH 2/4] Fix: Add missing bits from previous merge --- pyperf/pyperf_run | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index 8228ac5..a210573 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -18,7 +18,8 @@ PATH="${PATH}:/usr/local/bin" export PATH python_pkgs="" -python_exec="" +python_exec="python3" +install_pip=0 PYTHON_VERSION="" PYPERF_VERSION="1.11.0" # @@ -233,11 +234,12 @@ source test_tools/general_setup "$@" ARGUMENT_LIST=( "pyperf_version" "python_exec" - "python_pkgs" + "python_pkgs" ) NO_ARGUMENTS=( - "usage" + "usage" + "install_pip" ) # read arguments @@ -265,6 +267,10 @@ while [[ $# -gt 0 ]]; do python_pkgs=$2 shift 2 ;; + --install_pip) + install_pip=1 + shift 1 + ;; --usage) usage $0 ;; @@ -284,10 +290,7 @@ done if [ $to_pbench -eq 0 ]; then rm -rf pyperformance PYTHON_VERSION=$(python3 --version | awk '{ print $2 }') - python3 -m pip install pyperformance==$PYPERF_VERSION - if [ $? -ne 0 ]; then - exit_out "python3 -m pip install pyperformance==$PYPERF_VERSION: failed" 1 - fi + pip3_install "pyperformance==$PYPERF_VERSION" cd pyperformance if [[ ${python_pkgs} != "" ]]; then pkg_list=`echo $python_pkgs | sed "s/,/ /g"` From 68368599c697bfbeb43d198bb575ffe888ff63c2 Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Tue, 1 Apr 2025 14:31:13 -0400 Subject: [PATCH 3/4] Fix: Remove alternatives, changing branches was a pain --- pyperf/pyperf_run | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index a210573..2717f89 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -288,24 +288,15 @@ while [[ $# -gt 0 ]]; do done if [ $to_pbench -eq 0 ]; then - rm -rf pyperformance PYTHON_VERSION=$(python3 --version | awk '{ print $2 }') - pip3_install "pyperformance==$PYPERF_VERSION" - cd pyperformance if [[ ${python_pkgs} != "" ]]; then pkg_list=`echo $python_pkgs | sed "s/,/ /g"` test_tools/package_install --packages "$python_pkgs" --no_packages $to_no_pkg_install fi - if [[ $python_exec != "" ]]; then - if [[ ! -f $python_exec ]]; then - exit_out "Error: Designated python executable, $python_exec, not present" - fi - # - # Remove the existing (if any) default python. - # - alternatives --remove-all python - alternatives --install /usr/bin/python python $python_exec 1 + if ! command -v $python_exec; then + exit_out "Error: Designated python executable, $python_exec, not present" fi + pip3_install "pyperformance==$PYPERF_VERSION" pip3_install psutil pip3_install packaging pip3_install pyparsing From 3082c0b2cae6de67c208d8a257a40a0461aa8b41 Mon Sep 17 00:00:00 2001 From: Keith Valin Date: Tue, 1 Apr 2025 14:31:49 -0400 Subject: [PATCH 4/4] Fix: Replace python3 with python executable --- pyperf/pyperf_run | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index 2717f89..3a37533 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -288,7 +288,7 @@ while [[ $# -gt 0 ]]; do done if [ $to_pbench -eq 0 ]; then - PYTHON_VERSION=$(python3 --version | awk '{ print $2 }') + PYTHON_VERSION=$($python_exec --version | awk '{ print $2 }') if [[ ${python_pkgs} != "" ]]; then pkg_list=`echo $python_pkgs | sed "s/,/ /g"` test_tools/package_install --packages "$python_pkgs" --no_packages $to_no_pkg_install @@ -311,12 +311,12 @@ if [ $to_pbench -eq 0 ]; then $python_exec -m pyperformance run --output ${pyresults}.json if [ $? -ne 0 ]; then - exit_out "Failed: python3 -m pyperformance run --output ${pyresults}.json" 1 + exit_out "Failed: $python_exec -m pyperformance run --output ${pyresults}.json" 1 fi $python_exec -m pyperf dump ${pyresults}.json > ${pyresults}.results if [ $? -ne 0 ]; then - echo "Failed: python3 -m pyperf dump ${pyresults}.json > ${pyresults}.results" 1 + echo "Failed: $python_exec -m pyperf dump ${pyresults}.json > ${pyresults}.results" 1 echo Failed > test_results_report else echo Ran > test_results_report