1
1
#! /bin/bash
2
+ set -e
2
3
3
4
echo " Starting Open Interpreter installation..."
4
5
sleep 2
@@ -8,32 +9,110 @@ sleep 2
8
9
# Define pyenv location
9
10
pyenv_root=" $HOME /.pyenv/bin/pyenv"
10
11
11
- # Check if pyenv is installed
12
- if ! command -v $pyenv_root & > /dev/null
13
- then
14
- echo " pyenv is not installed. Installing now... "
15
- curl https://pyenv.run | zsh # zsh is the default shell for mac now. Changing this may cause install to fail
12
+ #! /bin/bash
13
+
14
+ # Check if Git is installed
15
+ if command -v git > /dev/null ; then
16
+ echo " Git is already installed. "
16
17
else
17
- echo " pyenv is already installed."
18
+ # Detect the operating system
19
+ OS=" $( uname -s) "
20
+
21
+ case " $OS " in
22
+ Linux)
23
+ # Assume a Debian-based or Fedora-based system
24
+ if command -v apt > /dev/null; then
25
+ echo " Installing Git on Debian-based Linux..."
26
+ # Check and install sudo if not present
27
+ if ! command -v sudo & > /dev/null; then
28
+ apt-get update && apt-get install -y sudo
29
+ fi
30
+ sudo apt install -y git-all
31
+ elif command -v dnf > /dev/null; then
32
+ echo " Installing Git on Fedora-based Linux..."
33
+ # Check and install sudo if not present
34
+ if ! command -v sudo & > /dev/null; then
35
+ dnf install -y sudo
36
+ fi
37
+ sudo dnf install -y git-all
38
+ else
39
+ echo " Package manager not supported. Please install Git manually."
40
+ fi
41
+ ;;
42
+ Darwin)
43
+ echo " Installing Git on macOS..."
44
+ # Install Git using Xcode Command Line Tools
45
+ xcode-select --install
46
+ ;;
47
+ * )
48
+ echo " Unsupported OS: $OS "
49
+ ;;
50
+ esac
18
51
fi
19
52
20
- PYENV_VERSION= ' 3.11.7 '
53
+ echo " Starting installation of pyenv... "
21
54
22
- $pyenv_root init
55
+ INSTALL_URL= " https://pyenv.run "
23
56
24
- $pyenv_root install $PYENV_VERSION --skip-existing
57
+ # Check if pyenv is already installed
58
+ if command -v pyenv & > /dev/null; then
59
+ echo " pyenv is already installed."
60
+ else
61
+ # Try to download and install pyenv using available commands
62
+ if command -v curl & > /dev/null; then
63
+ echo " Using curl to download pyenv..."
64
+ curl -L " $INSTALL_URL " | sh
65
+ # elif command -v wget &> /dev/null; then
66
+ # echo "Using wget to download pyenv..."
67
+ # wget -O- "$INSTALL_URL" | sh
68
+ # elif command -v python &> /dev/null; then
69
+ # echo "Using Python to download pyenv..."
70
+ # python -c "import urllib.request; exec(urllib.request.urlopen('$INSTALL_URL').read())"
71
+ # elif command -v perl &> /dev/null; then
72
+ # echo "Using Perl to download pyenv..."
73
+ # perl -e "use LWP::Simple; exec(get('$INSTALL_URL'))"
74
+ else
75
+ echo " Neither curl nor wget is available."
76
+ if [ " $( uname -s) " = " Linux" ]; then
77
+ echo " Linux detected. Attempting to install sudo and curl..."
78
+
79
+ # Check and install sudo if not present
80
+ if ! command -v sudo & > /dev/null; then
81
+ apt-get update && apt-get install -y sudo
82
+ fi
25
83
26
- $pyenv_root init
84
+ # Install curl using sudo
85
+ if command -v sudo & > /dev/null; then
86
+ sudo apt-get update && sudo apt-get install -y curl
87
+ if command -v curl & > /dev/null; then
88
+ echo " Using curl to download pyenv..."
89
+ curl -L " $INSTALL_URL " | sh
90
+ else
91
+ echo " Failed to install curl. Installation of pyenv cannot proceed."
92
+ fi
93
+ else
94
+ echo " Unable to install sudo. Manual installation required."
95
+ fi
96
+ else
97
+ echo " Failed to install curl. Installation of pyenv cannot proceed."
98
+ fi
99
+ fi
100
+ fi
27
101
28
- $pyenv_root global $PYENV_VERSION
102
+ # Install Python and remember the version
103
+ python_version=3.11
104
+ $pyenv_root install $python_version --skip-existing
29
105
30
- $pyenv_root exec pip install open-interpreter
106
+ # Explicitly use the installed Python version for commands
107
+ installed_version=$( $pyenv_root exec python$python_version --version)
108
+ echo " Installed Python version: $installed_version "
109
+ if [[ $installed_version != * " $python_version " * ]]; then
110
+ echo " Python $python_version was not installed correctly. Please open an issue at https://github.com/openinterpreter/universal-python/."
111
+ exit 1
112
+ fi
31
113
32
- $pyenv_root shell $PYENV_VERSION
33
- $pyenv_root pip install open-interpreter
34
- $pyenv_root shell --unset
114
+ # Use the specific Python version to install open-interpreter
115
+ $pyenv_root exec python$python_version -m pip install open-interpreter
35
116
36
- echo " "
37
- echo " Open Interpreter has been installed. Run the following command to use it: "
38
- echo " "
117
+ echo " Open Interpreter has been installed. Run the following command to use it:"
39
118
echo " interpreter"
0 commit comments