anurag008w commited on
Commit
470bb3f
·
1 Parent(s): be82891

Enhance pip installation handling in start.sh

Browse files

Refactor pip installation checks to skip capture when requirements are used and add support for 'uv' and 'pipx' commands.

Files changed (1) hide show
  1. start.sh +35 -4
start.sh CHANGED
@@ -1078,7 +1078,10 @@ pip() {
1078
  command pip "$@"
1079
  fi
1080
  local rc=$?
1081
- if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] && _hc_has_install_targets "${@:2}"; then
 
 
 
1082
  _hc_append_cmd "python3 -m pip install --user" "${@:2}"
1083
  fi
1084
  return $rc
@@ -1090,7 +1093,9 @@ pip3() {
1090
  command pip3 "$@"
1091
  fi
1092
  local rc=$?
1093
- if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] && _hc_has_install_targets "${@:2}"; then
 
 
1094
  _hc_append_cmd "python3 -m pip install --user" "${@:2}"
1095
  fi
1096
  return $rc
@@ -1102,7 +1107,9 @@ python() {
1102
  command python "$@"
1103
  fi
1104
  local rc=$?
1105
- if [ $rc -eq 0 ] && [ "${1:-}" = "-m" ] && [ "${2:-}" = "pip" ] && [ "${3:-}" = "install" ] && _hc_has_install_targets "${@:4}"; then
 
 
1106
  _hc_append_cmd "python3 -m pip install --user" "${@:4}"
1107
  fi
1108
  return $rc
@@ -1114,7 +1121,9 @@ python3() {
1114
  command python3 "$@"
1115
  fi
1116
  local rc=$?
1117
- if [ $rc -eq 0 ] && [ "${1:-}" = "-m" ] && [ "${2:-}" = "pip" ] && [ "${3:-}" = "install" ] && _hc_has_install_targets "${@:4}"; then
 
 
1118
  _hc_append_cmd "python3 -m pip install --user" "${@:4}"
1119
  fi
1120
  return $rc
@@ -1136,6 +1145,28 @@ openclaw() {
1136
  fi
1137
  return $rc
1138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
  BASHRC
1140
  cat > /home/node/.profile <<'PROFILE'
1141
  [ -n "${BASH_VERSION:-}" ] && [ -f ~/.bashrc ] && . ~/.bashrc
 
1078
  command pip "$@"
1079
  fi
1080
  local rc=$?
1081
+ # Skip capture when -r/--requirement is used: the requirements file won't exist on next boot
1082
+ if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] \
1083
+ && ! _hc_has_arg -r "${@:2}" && ! _hc_has_arg --requirement "${@:2}" \
1084
+ && _hc_has_install_targets "${@:2}"; then
1085
  _hc_append_cmd "python3 -m pip install --user" "${@:2}"
1086
  fi
1087
  return $rc
 
1093
  command pip3 "$@"
1094
  fi
1095
  local rc=$?
1096
+ if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] \
1097
+ && ! _hc_has_arg -r "${@:2}" && ! _hc_has_arg --requirement "${@:2}" \
1098
+ && _hc_has_install_targets "${@:2}"; then
1099
  _hc_append_cmd "python3 -m pip install --user" "${@:2}"
1100
  fi
1101
  return $rc
 
1107
  command python "$@"
1108
  fi
1109
  local rc=$?
1110
+ if [ $rc -eq 0 ] && [ "${1:-}" = "-m" ] && [ "${2:-}" = "pip" ] && [ "${3:-}" = "install" ] \
1111
+ && ! _hc_has_arg -r "${@:4}" && ! _hc_has_arg --requirement "${@:4}" \
1112
+ && _hc_has_install_targets "${@:4}"; then
1113
  _hc_append_cmd "python3 -m pip install --user" "${@:4}"
1114
  fi
1115
  return $rc
 
1121
  command python3 "$@"
1122
  fi
1123
  local rc=$?
1124
+ if [ $rc -eq 0 ] && [ "${1:-}" = "-m" ] && [ "${2:-}" = "pip" ] && [ "${3:-}" = "install" ] \
1125
+ && ! _hc_has_arg -r "${@:4}" && ! _hc_has_arg --requirement "${@:4}" \
1126
+ && _hc_has_install_targets "${@:4}"; then
1127
  _hc_append_cmd "python3 -m pip install --user" "${@:4}"
1128
  fi
1129
  return $rc
 
1145
  fi
1146
  return $rc
1147
  }
1148
+ # uv pip install — increasingly popular fast pip replacement
1149
+ uv() {
1150
+ command uv "$@"
1151
+ local rc=$?
1152
+ # Only capture: uv pip install ... (not uv pip sync, uv add, etc.)
1153
+ # Skip if -r/--requirements flag present (file won't exist on next boot)
1154
+ if [ $rc -eq 0 ] && [ "${1:-}" = "pip" ] && [ "${2:-}" = "install" ] \
1155
+ && ! _hc_has_arg -r "${@:3}" && ! _hc_has_arg --requirements "${@:3}" \
1156
+ && _hc_has_install_targets "${@:3}"; then
1157
+ _hc_append_cmd "uv pip install" "${@:3}"
1158
+ fi
1159
+ return $rc
1160
+ }
1161
+ # pipx — isolated tool installs
1162
+ pipx() {
1163
+ command pipx "$@"
1164
+ local rc=$?
1165
+ if [ $rc -eq 0 ] && [ "${1:-}" = "install" ] && _hc_has_install_targets "${@:2}"; then
1166
+ _hc_append_cmd "pipx install" "${@:2}"
1167
+ fi
1168
+ return $rc
1169
+ }
1170
  BASHRC
1171
  cat > /home/node/.profile <<'PROFILE'
1172
  [ -n "${BASH_VERSION:-}" ] && [ -f ~/.bashrc ] && . ~/.bashrc