From a3ccbb004a57c160f7c67e0efe7f90e65c2b6930 Mon Sep 17 00:00:00 2001 From: David Valin Date: Tue, 5 Sep 2023 13:10:47 -0400 Subject: [PATCH 1/3] Fix ubuntu --- pyperf/pyperf_run | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index 66d1475..9a70d1a 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -2,7 +2,7 @@ PATH="${PATH}:/usr/local/bin" export PATH -python_pkg="python3.11" +python_pkgs="" # # To make sure. # @@ -15,6 +15,7 @@ exit_out() usage() { echo "$1 Usage:" + echo "--python_pkgs python packages to install" source test_tools/general_setup --usage exit 1 } @@ -104,11 +105,19 @@ generate_csv_file() printf "%s:%12.2f:%s\n" $test_name $results $unit >> ${1}.csv } -dnf_install() +pkg_install() { - dnf install -y $1 - if [ $? -ne 0 ]; then - exit_out "dnf install of $1 failed" 1 + uname -a | grep Ubuntu > /dev/null + if [ $? -eq 0 ]; then + apt install -y $1 + if [ $? -ne 0 ]; then + exit_out "apt install of $1 failed" 1 + fi + else + dnf install -y $1 + if [ $? -ne 0 ]; then + exit_out "dnf install of $1 failed" 1 + fi fi } @@ -197,7 +206,7 @@ fi source test_tools/general_setup "$@" ARGUMENT_LIST=( - "python_pkg" + "python_pkgs" ) NO_ARGUMENTS=( @@ -217,8 +226,8 @@ eval set --$opts while [[ $# -gt 0 ]]; do case "$1" in - --python_pkg) - python_pkg=$2 + --python_pkgs) + python_pkgs=$2 shift 2 ;; --usage) @@ -248,8 +257,12 @@ if [ $to_pbench -eq 0 ]; then if [ $? -ne 0 ]; then exit_out "Checkout of 1.0.4 failed." 1 fi - dnf_install "${python_pkg}" - dnf_install "${python_pkg}-devel" + if [[ ${python_pkgs} != "" ]]; then + pkg_list=`echo $pkg_install | sed "s/,/ /g"` + for i in $pkg_list; do + pkg_install $i + done + fi # # Install pip/pip3 # From 29b2b068461467ca58ee7ec1535fec528b7c5093 Mon Sep 17 00:00:00 2001 From: David Valin Date: Fri, 8 Sep 2023 11:50:37 -0400 Subject: [PATCH 2/3] use detect_os and allow designating python to use. --- pyperf/pyperf_run | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index 9a70d1a..605ba42 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -3,6 +3,9 @@ PATH="${PATH}:/usr/local/bin" export PATH python_pkgs="" +test_tools/detect_os | grep Ubuntu > /dev/null +ubuntu=$? +python_exec="" # # To make sure. # @@ -15,7 +18,8 @@ exit_out() usage() { echo "$1 Usage:" - echo "--python_pkgs python packages to install" + echo "--python_exec_path: Python to set via alternatives" + echo "--python_pkgs: comma seprated list of python packages to install" source test_tools/general_setup --usage exit 1 } @@ -107,8 +111,7 @@ generate_csv_file() pkg_install() { - uname -a | grep Ubuntu > /dev/null - if [ $? -eq 0 ]; then + if [ $ubuntu -eq 0 ]; then apt install -y $1 if [ $? -ne 0 ]; then exit_out "apt install of $1 failed" 1 @@ -206,6 +209,7 @@ fi source test_tools/general_setup "$@" ARGUMENT_LIST=( + "python_exec" "python_pkgs" ) @@ -226,6 +230,10 @@ eval set --$opts while [[ $# -gt 0 ]]; do case "$1" in + --python_exec) + python_exec=$2 + shift 2 + ;; --python_pkgs) python_pkgs=$2 shift 2 @@ -258,11 +266,22 @@ if [ $to_pbench -eq 0 ]; then exit_out "Checkout of 1.0.4 failed." 1 fi if [[ ${python_pkgs} != "" ]]; then - pkg_list=`echo $pkg_install | sed "s/,/ /g"` + pkg_list=`echo $python_pkgs | sed "s/,/ /g"` + echo pkg_list $pkg_list >>/tmp/dave for i in $pkg_list; do pkg_install $i done 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 + fi # # Install pip/pip3 # From de1a7fe7364ce997e8d4d2b5e144ee14e84454a2 Mon Sep 17 00:00:00 2001 From: David Valin Date: Fri, 8 Sep 2023 11:52:04 -0400 Subject: [PATCH 3/3] Remove extra space --- pyperf/pyperf_run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyperf/pyperf_run b/pyperf/pyperf_run index 605ba42..b385fdb 100755 --- a/pyperf/pyperf_run +++ b/pyperf/pyperf_run @@ -268,7 +268,7 @@ if [ $to_pbench -eq 0 ]; then if [[ ${python_pkgs} != "" ]]; then pkg_list=`echo $python_pkgs | sed "s/,/ /g"` echo pkg_list $pkg_list >>/tmp/dave - for i in $pkg_list; do + for i in $pkg_list; do pkg_install $i done fi