18
18
PATH=" ${PATH} :/usr/local/bin"
19
19
export PATH
20
20
python_pkgs=" "
21
- python_exec=" "
21
+ python_exec=" python3"
22
+ install_pip=0
22
23
PYTHON_VERSION=" "
23
24
PYPERF_VERSION=" 1.11.0"
24
25
#
@@ -132,12 +133,23 @@ generate_csv_file()
132
133
133
134
pip3_install ()
134
135
{
135
- if [ $to_no_pkg_install -eq 0 ]; then
136
- pip3 -q install $1
137
- if [ $? -ne 0 ]; then
138
- exit_out " pip3 install of $1 failed." 1
136
+ if [ $to_no_pkg_install -eq 1 ]; then
137
+ return
138
+ fi
139
+
140
+ $python_exec -m pip --version
141
+ if [[ $? -ne 0 ]]; then
142
+ if [[ $install_pip -eq 1 ]]; then
143
+ $python_exec -m ensurepip || exit_out " Failed to install pip." 1
144
+ else
145
+ exit_out " Pip is not available, exiting out" 1
139
146
fi
140
147
fi
148
+
149
+ $python_exec -m pip install -q $1
150
+ if [[ $? -ne 0 ]]; then
151
+ exit_out " Pip not available for install of $1 failed." 1
152
+ fi
141
153
}
142
154
#
143
155
# Variables set by general setup.
@@ -222,11 +234,12 @@ source test_tools/general_setup "$@"
222
234
ARGUMENT_LIST=(
223
235
" pyperf_version"
224
236
" python_exec"
225
- " python_pkgs"
237
+ " python_pkgs"
226
238
)
227
239
228
240
NO_ARGUMENTS=(
229
- " usage"
241
+ " usage"
242
+ " install_pip"
230
243
)
231
244
232
245
# read arguments
@@ -254,6 +267,10 @@ while [[ $# -gt 0 ]]; do
254
267
python_pkgs=$2
255
268
shift 2
256
269
;;
270
+ --install_pip)
271
+ install_pip=1
272
+ shift 1
273
+ ;;
257
274
--usage)
258
275
usage $0
259
276
;;
@@ -271,27 +288,15 @@ while [[ $# -gt 0 ]]; do
271
288
done
272
289
273
290
if [ $to_pbench -eq 0 ]; then
274
- rm -rf pyperformance
275
- PYTHON_VERSION=$( python3 --version | awk ' { print $2 }' )
276
- python3 -m pip install pyperformance==$PYPERF_VERSION
277
- if [ $? -ne 0 ]; then
278
- exit_out " python3 -m pip install pyperformance==$PYPERF_VERSION : failed" 1
279
- fi
280
- cd pyperformance
291
+ PYTHON_VERSION=$( $python_exec --version | awk ' { print $2 }' )
281
292
if [[ ${python_pkgs} != " " ]]; then
282
293
pkg_list=` echo $python_pkgs | sed " s/,/ /g" `
283
294
test_tools/package_install --packages " $python_pkgs " --no_packages $to_no_pkg_install
284
295
fi
285
- if [[ $python_exec != " " ]]; then
286
- if [[ ! -f $python_exec ]]; then
287
- exit_out " Error: Designated python executable, $python_exec , not present"
288
- fi
289
- #
290
- # Remove the existing (if any) default python.
291
- #
292
- alternatives --remove-all python
293
- alternatives --install /usr/bin/python python $python_exec 1
296
+ if ! command -v $python_exec ; then
297
+ exit_out " Error: Designated python executable, $python_exec , not present"
294
298
fi
299
+ pip3_install " pyperformance==$PYPERF_VERSION "
295
300
pip3_install psutil
296
301
pip3_install packaging
297
302
pip3_install pyparsing
@@ -303,16 +308,15 @@ if [ $to_pbench -eq 0 ]; then
303
308
mkdir python_results
304
309
305
310
pyresults=python_results/pyperf_out_$( date " +%Y.%m.%d-%H.%M.%S" )
306
- pwd > /tmp/dave_debug
307
- echo python3 -m pyperformance run --output ${pyresults} .json >> /tmp/dave_debug
308
- python3 -m pyperformance run --output ${pyresults} .json
311
+
312
+ $python_exec -m pyperformance run --output ${pyresults} .json
309
313
if [ $? -ne 0 ]; then
310
- exit_out " Failed: python3 -m pyperformance run --output ${pyresults} .json" 1
314
+ exit_out " Failed: $python_exec -m pyperformance run --output ${pyresults} .json" 1
311
315
fi
312
- echo python3 -m pyperf dump ${pyresults} .json >> /tmp/dave_debug
313
- python3 -m pyperf dump ${pyresults} .json > ${pyresults} .results
316
+
317
+ $python_exec -m pyperf dump ${pyresults} .json > ${pyresults} .results
314
318
if [ $? -ne 0 ]; then
315
- echo " Failed: python3 -m pyperf dump ${pyresults} .json > ${pyresults} .results" 1
319
+ echo " Failed: $python_exec -m pyperf dump ${pyresults} .json > ${pyresults} .results" 1
316
320
echo Failed > test_results_report
317
321
else
318
322
echo Ran > test_results_report
0 commit comments