1
1
#! /bin/bash
2
2
3
- # Exit on any error
4
3
set -e
5
4
6
5
# Configuration
7
- VENV_DIR=" $HOME /.openinterpreter"
8
- INSTALL_DIR=" $HOME /.local/bin"
9
- PYTHON_VERSION=" 3.12"
10
6
REPO_URL=" https://github.com/OpenInterpreter/open-interpreter.git"
11
7
BRANCH=" development"
12
- COMMANDS=(" interpreter" " i" " wtf" )
13
-
14
- # Print error message and exit
15
- error_exit () {
16
- echo " Error: $1 " >&2
17
- exit 1
18
- }
19
-
20
- # Check if command exists
21
- command_exists () {
22
- command -v " $1 " > /dev/null 2>&1
23
- }
24
-
25
- # Get installation path of a command
26
- get_command_path () {
27
- which " $1 " 2> /dev/null || echo " "
28
- }
29
-
30
- # Handle existing installations
31
- check_and_handle_existing () {
32
- local found_existing=false
33
- local paths_to_remove=()
34
-
35
- # Check for pip installation
36
- if pip show open-interpreter > /dev/null 2>&1 ; then
37
- found_existing=true
38
- echo " Found existing pip installation of open-interpreter"
39
- read -p " Would you like to uninstall it? [y/N] " -n 1 -r
40
- echo
41
- if [[ $REPLY =~ ^[Yy]$ ]]; then
42
- echo " Uninstalling open-interpreter via pip..."
43
- pip uninstall -y open-interpreter || echo " Failed to uninstall via pip"
44
- fi
45
- fi
46
-
47
- # Check for command installations
48
- for cmd in " ${COMMANDS[@]} " ; do
49
- local cmd_path=$( get_command_path " $cmd " )
50
- if [ -n " $cmd_path " ]; then
51
- found_existing=true
52
- echo " Found existing installation of '$cmd ' at: $cmd_path "
53
- paths_to_remove+=(" $cmd_path " )
54
- fi
55
- done
56
-
57
- # If command installations were found, ask to remove them
58
- if [ ${# paths_to_remove[@]} -gt 0 ]; then
59
- echo
60
- echo " Found existing command installations:"
61
- printf ' %s\n' " ${paths_to_remove[@]} "
62
- read -p " Would you like to remove these files? [y/N] " -n 1 -r
63
- echo
64
- if [[ $REPLY =~ ^[Yy]$ ]]; then
65
- for path in " ${paths_to_remove[@]} " ; do
66
- echo " Removing: $path "
67
- rm -f " $path " || echo " Failed to remove: $path "
68
- done
69
- fi
70
- fi
71
-
72
- # If any existing installations were found but user chose not to remove them,
73
- # ask if they want to continue
74
- if [ " $found_existing " = true ]; then
75
- echo
76
- read -p " Continue with installation anyway? [y/N] " -n 1 -r
77
- echo
78
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
79
- echo " Installation cancelled."
80
- exit 0
81
- fi
82
- fi
83
- }
8
+ PYTHON_VERSION=" 3.12"
84
9
85
- # Install uv package manager
86
- install_uv () {
10
+ # Install uv if not present
11
+ if ! command -v uv > /dev/null 2>&1 ; then
87
12
echo " Installing uv package manager..."
88
- if command_exists curl; then
13
+ if command -v curl > /dev/null 2>&1 ; then
89
14
curl -LsSf https://astral.sh/uv/install.sh | sh
90
- elif command_exists wget; then
91
- wget -qO- https://astral.sh/uv/install.sh | sh
92
15
else
93
- error_exit " Neither curl nor wget is available. Please install one of them first. "
16
+ wget -qO- https://astral.sh/uv/ install.sh | sh
94
17
fi
95
-
96
- # Update PATH to include cargo binaries
97
18
export PATH=" $HOME /.cargo/bin:$PATH "
98
-
99
- # Verify uv installation
100
- if ! command_exists uv; then
101
- error_exit " Failed to install uv package manager"
102
- fi
103
- }
19
+ fi
104
20
105
- # Create virtual environment and install package
106
- setup_environment () {
107
- echo " Creating virtual environment..."
108
- mkdir -p " $VENV_DIR "
109
- uv venv --python " $PYTHON_VERSION " " $VENV_DIR /venv"
110
-
111
- echo " Installing open-interpreter from $BRANCH branch..."
112
- uv pip install --python " $VENV_DIR /venv/bin/python" " git+$REPO_URL @$BRANCH "
113
- }
114
-
115
- # Create symbolic links
116
- create_symlinks () {
117
- echo " Creating command symlinks..."
118
- mkdir -p " $INSTALL_DIR "
119
- for cmd in " ${COMMANDS[@]} " ; do
120
- ln -sf " $VENV_DIR /venv/bin/$cmd " " $INSTALL_DIR /$cmd "
121
- done
122
- }
123
-
124
- # Main installation process
125
- main () {
126
- echo " Starting Open Interpreter installation..."
127
-
128
- # Check and handle existing installations first
129
- check_and_handle_existing
130
-
131
- if ! command_exists uv; then
132
- install_uv
133
- fi
134
-
135
- setup_environment
136
- create_symlinks
137
-
138
- echo
139
- echo " Installation complete! The commands '${COMMANDS[*]} ' are now available."
140
- echo " If they're not found, you may need to add ~/.local/bin to your PATH:"
141
- echo ' export PATH="$HOME/.local/bin:$PATH"'
142
- }
21
+ # Direct installation using uv with specific Python version
22
+ echo " Installing package..."
23
+ uv pip install --python " $PYTHON_VERSION " " git+$REPO_URL @$BRANCH "
143
24
144
- # Run main function
145
- main
25
+ echo
26
+ echo " Installation complete! "
0 commit comments