@@ -168,7 +168,7 @@ function _remove_old_target_dep_recursively
168
168
old_dep_dep_file=" ${TUE_INSTALL_DEPENDENCIES_DIR} " /" ${old_dep_target} "
169
169
if [[ -f " ${old_dep_dep_file} " ]]
170
170
then
171
- # Iterate over all depencies of old_dep_target, which is removed.
171
+ # Iterate over all dependencies of old_dep_target, which is removed.
172
172
while read -r dep_of_old_dep
173
173
do
174
174
# Actually remove the deps
@@ -183,11 +183,11 @@ function _remove_old_target_dep_recursively
183
183
done < " ${old_dep_dep_file} "
184
184
rm -f " ${old_dep_dep_file} "
185
185
else
186
- tue-install-debug " [remove_old_dep] No depencies file exist for target: ${old_dep_target} "
186
+ tue-install-debug " [remove_old_dep] No dependencies file exist for target: ${old_dep_target} "
187
187
fi
188
188
189
189
tue-install-debug " [remove_old_dep] Uninstalled '${old_dep_target} ' as a dependency of '${parent_target} '"
190
- tue-install-info " [remove_old_dep] '${old_dep_target} ' has been uninstalled, you can remove it from the workspace or deinstall it in another way"
190
+ tue-install-info " [remove_old_dep] '${old_dep_target} ' has been uninstalled, you can remove it from the workspace or uninstall it in another way"
191
191
return ${error_code}
192
192
}
193
193
@@ -309,7 +309,7 @@ function tue-install-target
309
309
[ " $now " == " true" ] && now_cmd=" --now"
310
310
# Do not use 'local cmds=' because it does not preserve command output status ($?)
311
311
local cmds
312
- if cmds=$( " $ TUE_INSTALL_SCRIPTS_DIR" /parse_install_yaml.py " $install_file " .yaml $now_cmd )
312
+ if cmds=$( /usr/bin/python " ${ TUE_INSTALL_SCRIPTS_DIR} " /parse_install_yaml.py " ${ install_file} " .yaml ${ now_cmd} )
313
313
then
314
314
for cmd in $cmds
315
315
do
@@ -352,7 +352,7 @@ function tue-install-target
352
352
old_deps_removed=$( comm -23 <( echo " ${old_deps} " ) <( echo " ${new_deps} " ) )
353
353
if [[ -n ${old_deps_removed} ]]
354
354
then
355
- tue-install-debug " Following dropped depedencies need to be removed:\n${old_deps_removed} "
355
+ tue-install-debug " Following dropped dependencies need to be removed:\n${old_deps_removed} "
356
356
else
357
357
tue-install-debug " No dropped dependencies to be removed"
358
358
fi
@@ -361,7 +361,7 @@ function tue-install-target
361
361
do
362
362
# Remove this target from dep-on file of dep
363
363
# When the dep-on file is now empty, remove it
364
- # Recurisvely -> Remove it from the dep-on files of its deps
364
+ # Recursively -> Remove it from the dep-on files of its deps
365
365
tue-install-debug " Going to remove '${dep} ' as a dependency"
366
366
_remove_old_target_dep_recursively " ${target} " " ${dep} " || tue-install-error " Something went wrong while removing '${dep} ' as a dependency"
367
367
done
@@ -1093,6 +1093,49 @@ function tue-install-pip3
1093
1093
1094
1094
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1095
1095
1096
+ function _handle_python_sites
1097
+ {
1098
+ local pv
1099
+ pv=$1
1100
+ shift
1101
+ # requires the parent function to have declared the following local variables:
1102
+ # python_exec, site_arg, sudo_cmd, user_arg
1103
+ tue-install-debug " _handle_python${pv} _sites $* "
1104
+
1105
+ local site
1106
+ site=$1
1107
+
1108
+ case ${site} in
1109
+ " system" )
1110
+ python_exec=/usr/bin/python" ${pv} "
1111
+ site_arg=" -s"
1112
+ sudo_cmd=" sudo -H"
1113
+ user_arg=" "
1114
+ ;;
1115
+ " user" )
1116
+ python_exec=/usr/bin/python" ${pv} "
1117
+ site_arg=" "
1118
+ sudo_cmd=" "
1119
+ user_arg=" --user"
1120
+ ;;
1121
+ " venv" )
1122
+ python_exec=python" ${pv} "
1123
+ site_arg=" -s"
1124
+ sudo_cmd=" "
1125
+ user_arg=" "
1126
+ ;;
1127
+ * )
1128
+ tue-install-error " _handle_python${pv} _sites: Unknown input variable ${i} "
1129
+ ;;
1130
+ esac
1131
+
1132
+ tue-install-debug " python_site: ${python_site} "
1133
+ tue-install-debug " python_exec: ${python_exec} "
1134
+ tue-install-debug " site_arg: ${site_arg} "
1135
+ tue-install-debug " sudo_cmd: ${sudo_cmd} "
1136
+ tue-install-debug " user_arg: ${user_arg} "
1137
+ }
1138
+
1096
1139
function _tue-install-pip-now
1097
1140
{
1098
1141
local pv
@@ -1105,25 +1148,42 @@ function _tue-install-pip-now
1105
1148
tue-install-error " Invalid tue-install-pip${pv} -now call: needs package as argument."
1106
1149
fi
1107
1150
1108
- local user_arg
1109
- [[ -z " ${VIRTUAL_ENV} " ]] && user_arg=" --user"
1151
+ local pips python_site
1152
+ { [[ -n ${VIRTUAL_ENV} ]] && python_site=" venv" ; } || python_site=" user"
1153
+ if [[ -n $1 ]]
1154
+ then
1155
+ for i in " $@ "
1156
+ do
1157
+ case $i in
1158
+ --python-site=* )
1159
+ python_site=" ${i#* =} "
1160
+ ;;
1161
+ --* )
1162
+ tue-install-error " tue-install-pip${pv} -now: Unknown input variable ${i} " ;;
1163
+ * )
1164
+ pips+=(" $i " ) ;;
1165
+ esac
1166
+ done
1167
+ fi
1168
+
1169
+ local python_exec site_arg sudo_cmd user_arg
1170
+ _handle_python_sites " ${pv} " " ${python_site} "
1110
1171
1111
1172
# Make sure pip is up-to-date before checking version and installing
1112
1173
local pip_version desired_pip_version
1113
- pip_version=$( python" ${pv} " -m pip --version | awk ' {print $2}' )
1174
+ pip_version=$( python" ${pv} " ${site_arg} -m pip --version | awk ' {print $2}' )
1114
1175
desired_pip_version=" 23"
1115
1176
if version_gt " $desired_pip_version " " $pip_version "
1116
1177
then
1117
1178
tue-install-debug " pip${pv} not yet version >=$desired_pip_version , but $pip_version "
1118
- tue-install-pipe python" ${pv} " -m pip install ${user_arg} --upgrade pip
1179
+ tue-install-pipe python" ${pv} " ${site_arg} -m pip install " ${user_arg} " --upgrade pip
1119
1180
hash -r
1120
1181
else
1121
1182
tue-install-debug " Already pip${pv} >=$desired_pip_version "
1122
1183
fi
1123
1184
1124
1185
local pips_to_check pips_to_check_w_options pips_to_install pips_to_install_w_options git_pips_to_install
1125
- # shellcheck disable=SC2048
1126
- for pkg in $*
1186
+ for pkg in " ${pips[@]} "
1127
1187
do
1128
1188
if [[ " $pkg " == " git+" * ]]
1129
1189
then
@@ -1143,7 +1203,7 @@ function _tue-install-pip-now
1143
1203
then
1144
1204
local indexes_to_install
1145
1205
# shellcheck disable=SC2086
1146
- _tue-install-pip-check " $pv " $ pips_to_check
1206
+ _tue-install-pip-check " ${pv} " --python-site= ${python_site} ${ pips_to_check}
1147
1207
1148
1208
read -r -a pips_to_check <<< " $pips_to_check"
1149
1209
@@ -1165,7 +1225,7 @@ function _tue-install-pip-now
1165
1225
pips_to_check_options_removed=" $pips_to_check_options_removed ${pkg_split[0]} "
1166
1226
done
1167
1227
# shellcheck disable=SC2086
1168
- _tue-install-pip-check " $pv " $ pips_to_check_options_removed
1228
+ _tue-install-pip-check " ${pv} " --python-site= ${python_site} ${ pips_to_check_options_removed}
1169
1229
1170
1230
read -r -a pips_to_check_w_options <<< " $pips_to_check_w_options"
1171
1231
@@ -1181,15 +1241,15 @@ function _tue-install-pip-now
1181
1241
if [ -n " $pips_to_install " ]
1182
1242
then
1183
1243
# shellcheck disable=SC2048,SC2086
1184
- tue-install-pipe python " ${pv} " -m pip install ${user_arg} $pips_to_install <<< yes || tue-install-error " An error occurred while installing pip${pv} packages."
1244
+ tue-install-pipe ${sudo_cmd} ${python_exec} ${site_arg} -m pip install ${user_arg} $pips_to_install <<< yes || tue-install-error " An error occurred while installing pip${pv} packages."
1185
1245
fi
1186
1246
1187
1247
if [ -n " $pips_to_install_w_options " ]
1188
1248
then
1189
1249
for pkg in $pips_to_install_w_options
1190
1250
do
1191
1251
# shellcheck disable=SC2048,SC2086
1192
- tue-install-pipe python " ${pv} " -m pip install ${user_arg} ${pkg// ^/ } <<< yes || tue-install-error " An error occurred while installing pip${pv} packages with options."
1252
+ tue-install-pipe ${sudo_cmd} ${python_exec} ${site_arg} -m pip install ${user_arg} ${pkg// ^/ } <<< yes || tue-install-error " An error occurred while installing pip${pv} packages with options."
1193
1253
done
1194
1254
fi
1195
1255
@@ -1198,7 +1258,7 @@ function _tue-install-pip-now
1198
1258
for pkg in $git_pips_to_install
1199
1259
do
1200
1260
# shellcheck disable=SC2048,SC2086
1201
- tue-install-pipe python " ${pv} " -m pip install ${user_arg} ${pkg} <<< yes || tue-install-error " An error occurred while installing pip${pv} git packages."
1261
+ tue-install-pipe ${sudo_cmd} ${python_exec} ${site_arg} -m pip install ${user_arg} ${pkg} <<< yes || tue-install-error " An error occurred while installing pip${pv} git packages."
1202
1262
done
1203
1263
fi
1204
1264
}
@@ -1210,12 +1270,36 @@ function _tue-install-pip-check
1210
1270
pv=$1
1211
1271
shift
1212
1272
1213
- local pips_to_check installed_versions
1214
- pips_to_check=(" $@ " )
1273
+ local installed_versions python_site pips_to_check
1274
+ if [[ -n $1 ]]
1275
+ then
1276
+ for i in " $@ "
1277
+ do
1278
+ case $i in
1279
+ --python-site=* )
1280
+ python_site=" ${i#* =} "
1281
+ ;;
1282
+ --* )
1283
+ tue-install-error " Unknown input variable ${i} " ;;
1284
+ * )
1285
+ pips_to_check+=(" $i " ) ;;
1286
+ esac
1287
+ done
1288
+ fi
1289
+
1290
+ if [[ -z " ${VIRTUAL_ENV} " && " ${site} " == " venv" ]]
1291
+ then
1292
+ tue-install-error " Trying to check pip packages in a virtualenv, but no virtualenv is activated"
1293
+ fi
1294
+
1295
+ # Set by _handle_python_sites
1296
+ local python_exec sudo_cmd site_arg user_arg
1297
+ _handle_python_sites " ${pv} " " ${python_site} "
1298
+
1215
1299
if [ ${# pips_to_check[@]} -gt 0 ]
1216
1300
then
1217
1301
local error_code
1218
- installed_versions=$( python " ${pv } " " $ TUE_INSTALL_SCRIPTS_DIR" /check-pip-pkg-installed-version.py " ${pips_to_check[@]} " )
1302
+ installed_versions=$( ${sudo_cmd} " ${python_exec } " ${site_arg} " ${ TUE_INSTALL_SCRIPTS_DIR} " /check-pip-pkg-installed-version.py " ${pips_to_check[@]} " )
1219
1303
error_code=$?
1220
1304
if [ " $error_code " -gt 1 ]
1221
1305
then
@@ -1493,10 +1577,11 @@ function tue-install-ros
1493
1577
local pkg_xml=" $ros_pkg_dir " /package.xml
1494
1578
if [ -f " $pkg_xml " ]
1495
1579
then
1496
- # Catkin
1580
+ # catkin/ament/colcon
1497
1581
tue-install-debug " Parsing $pkg_xml "
1582
+
1498
1583
local deps
1499
- deps=$( " $ TUE_INSTALL_SCRIPTS_DIR" /parse_package_xml.py " $pkg_xml " )
1584
+ deps=$( /usr/bin/python " ${ TUE_INSTALL_SCRIPTS_DIR} " /parse_package_xml.py " ${ pkg_xml} " )
1500
1585
tue-install-debug " Parsed package.xml\n$deps "
1501
1586
1502
1587
for dep in $deps
@@ -1636,7 +1721,8 @@ TUE_INSTALL_INFOS=
1636
1721
# Make sure tools used by this installer are installed
1637
1722
tue-install-system-now curl git jq python-is-python3 python3-pip wget
1638
1723
1639
- tue-install-pip3-now catkin-pkg PyYAML
1724
+ # Install in user or system site-packages
1725
+ tue-install-pip3-now --python-site=" user" catkin-pkg PyYAML
1640
1726
1641
1727
1642
1728
# Handling of targets
1674
1760
tue-install-debug " [$target ] marked as installed after a successful install"
1675
1761
touch " $TUE_INSTALL_INSTALLED_DIR " /" $target "
1676
1762
else
1677
- tue-install-debug " [$target ] succesfully updated"
1763
+ tue-install-debug " [$target ] successfully updated"
1678
1764
fi
1679
1765
done
1680
1766
1746
1832
1747
1833
TUE_INSTALL_CURRENT_TARGET=" main-loop"
1748
1834
1749
- tue-install-echo " Installer completed succesfully "
1835
+ tue-install-echo " Installer completed successfully "
1750
1836
1751
1837
return 0
0 commit comments