@@ -22,6 +22,7 @@ PYTHON_VERSION=">=3.10,<3.13"
22
22
UV_INSTALLER_URL=" https://astral.sh/uv/install.sh"
23
23
PYTHON_BIN_PATH=" " # set after a verified install is found
24
24
DEV_BRANCH=" " # set by --dev-branch flag
25
+ DO_UNINSTALL=0 # set by uninstall flag
25
26
PRINT_VERBOSE=0
26
27
PRINT_QUIET=1
27
28
@@ -43,6 +44,13 @@ Run 'agentstack update' to update to the latest version.
43
44
EOF
44
45
)
45
46
47
+ MSG_UNINSTALL=$( cat << EOF
48
+ ✅ AgentStack has been uninstalled.
49
+ If you encountered any issues, or have feedback, please open an issue:
50
+ $REPO_URL /issues
51
+ EOF
52
+ )
53
+
46
54
usage () {
47
55
cat << EOF
48
56
agentstack-install.sh
56
64
agentstack-install.sh [OPTIONS]
57
65
58
66
OPTIONS:
67
+ uninstall Uninstall
59
68
--version=<version> Specify version to install (default: $VERSION )
60
69
--python-version=<version> Specify Python version to install (default: $PYTHON_VERSION )
61
70
--dev-branch=<branch> Install from a specific git branch/commit/tag
@@ -114,7 +123,7 @@ err() {
114
123
say " \n${_red} [ERROR]${_reset} : $1 " >&2
115
124
say " \nRun with --verbose for more details."
116
125
say " \nIf you need help, please feel free to open an issue:"
117
- say " \n $REPO_URL /issues\n"
126
+ say " $REPO_URL /issues\n"
118
127
fi
119
128
exit 1
120
129
}
@@ -225,10 +234,12 @@ install_uv() {
225
234
err " uv installation failed: $_output "
226
235
fi
227
236
237
+ update_path " $HOME /.local/bin"
238
+
228
239
# verify uv installation
229
240
local _uv_version
230
241
_uv_version=" $( uv --version 2> /dev/null) " || {
231
- _uv_version=0
242
+ err " could not find uv "
232
243
}
233
244
234
245
end_activity
@@ -396,8 +407,10 @@ setup_app() {
396
407
update_path () {
397
408
local new_path=" $1 "
398
409
399
- # update for current session
400
- export PATH=" $new_path :$PATH "
410
+ # update for current session if not already set
411
+ if ! echo $PATH | grep -q " $new_path " ; then
412
+ export PATH=" $new_path :$PATH "
413
+ fi
401
414
402
415
# update for each shell
403
416
local config_files=(
437
450
chmod +x $_program_bin
438
451
}
439
452
453
+ uninstall () {
454
+ say " Uninstalling $APP_NAME ..."
455
+ show_activity
456
+
457
+ update_path " $HOME /.local/bin"
458
+ PYTHON_BIN_PATH=" $( uv python find " $PYTHON_VERSION " 2> /dev/null) " || {
459
+ PYTHON_BIN_PATH=" "
460
+ }
461
+
462
+ # uninstall the app
463
+ local _packages_dir=" $( $PYTHON_BIN_PATH -m site --user-site 2> /dev/null) " || {
464
+ err " Failed to find user site packages directory"
465
+ }
466
+ say_verbose " Uninstalling from $_packages_dir "
467
+ local _uninstall_cmd=" uv pip uninstall --python=" $PYTHON_BIN_PATH " --target=" $_packages_dir " $APP_NAME "
468
+ say_verbose " $_uninstall_cmd "
469
+ local _uninstall_out=" $( eval " $_uninstall_cmd " 2>&1 ) "
470
+ say_verbose " $_uninstall_out "
471
+ if [ $? -ne 0 ] || echo " $_uninstall_out " | grep -qi " error\|failed\|exception" ; then
472
+ err " Failed to uninstall $APP_NAME ."
473
+ fi
474
+
475
+ # remove the bin file
476
+ rm -f " $HOME /.local/bin/$APP_NAME "
477
+
478
+ end_activity
479
+ }
480
+
440
481
# Download a file. Try curl first, if not installed, use wget instead.
441
482
download_file () {
442
483
local _url=" $1 "
@@ -487,6 +528,10 @@ verify_sha256_checksum() {
487
528
parse_args () {
488
529
while [[ $# -gt 0 ]]; do
489
530
case " $1 " in
531
+ uninstall)
532
+ DO_UNINSTALL=1
533
+ shift
534
+ ;;
490
535
--version=* )
491
536
VERSION=" ${1#* =} "
492
537
shift
@@ -562,6 +607,12 @@ main() {
562
607
563
608
say " $LOGO \n"
564
609
610
+ if [ $DO_UNINSTALL -eq 1 ]; then
611
+ uninstall
612
+ say " \n$MSG_UNINSTALL \n"
613
+ exit 0
614
+ fi
615
+
565
616
if check_cmd $APP_NAME ; then
566
617
say " \n$MSG_ALREADY_INSTALLED \n"
567
618
exit 0
0 commit comments