Skip to content

Commit 99ec6f6

Browse files
authored
Merge pull request #1395 from CyanideByte/conda-installer
Conda installer
2 parents a5dbbf5 + ae51e90 commit 99ec6f6

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

docs/assets/favicon.ico

8.85 KB
Binary file not shown.

docs/getting-started/setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ curl -sL https://raw.githubusercontent.com/KillianLucas/open-interpreter/main/in
6969
```
7070

7171
```powershell Windows
72-
iex "& {$(irm https://raw.githubusercontent.com/KillianLucas/open-interpreter/main/installers/oi-windows-installer.ps1)}"
72+
iex "& {$(irm https://raw.githubusercontent.com/KillianLucas/open-interpreter/main/installers/oi-windows-installer-conda.ps1)}"
7373
```
7474

7575
```bash Linux
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Define variables
2+
$condaInstallerUrl = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
3+
$condaInstallerPath = "$env:TEMP\Miniconda3-latest-Windows-x86_64.exe"
4+
$condaPath = "$env:USERPROFILE\Miniconda3"
5+
$envName = "oi"
6+
$pythonVersion = "3.11.7"
7+
$packageName = "open-interpreter litellm openai"
8+
$desktopPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath('Desktop'), 'Open Interpreter.lnk')
9+
$condaExePath = "$condaPath\Scripts\conda.exe"
10+
11+
# URL of the .ico file
12+
$icoUrl = "https://raw.githubusercontent.com/OpenInterpreter/open-interpreter/main/docs/assets/favicon.ico"
13+
$icoPath = "$env:TEMP\open-interpreter.ico"
14+
15+
# Function to download a file with progress
16+
function DownloadFileWithProgress {
17+
param (
18+
[string]$url,
19+
[string]$output
20+
)
21+
22+
$request = [System.Net.HttpWebRequest]::Create($url)
23+
$response = $request.GetResponse()
24+
$totalLength = $response.ContentLength
25+
$readBytes = 0
26+
$buffer = New-Object byte[] 1024
27+
$percentComplete = 0
28+
29+
$stream = $response.GetResponseStream()
30+
$fileStream = New-Object IO.FileStream ($output, [System.IO.FileMode]::Create)
31+
32+
try {
33+
while (($read = $stream.Read($buffer, 0, $buffer.Length)) -gt 0) {
34+
$fileStream.Write($buffer, 0, $read)
35+
$readBytes += $read
36+
$newPercentComplete = [math]::Round(($readBytes / $totalLength) * 100)
37+
38+
if ($newPercentComplete -ne $percentComplete) {
39+
$percentComplete = $newPercentComplete
40+
Write-Progress -Activity "Downloading Miniconda Installer" -Status "$percentComplete% Complete" -PercentComplete $percentComplete
41+
}
42+
}
43+
} finally {
44+
$fileStream.Close()
45+
$stream.Close()
46+
}
47+
48+
Write-Progress -Activity "Downloading Miniconda Installer" -Completed
49+
}
50+
51+
# Download the .ico file
52+
Write-Host "Downloading icon file..."
53+
DownloadFileWithProgress -url $icoUrl -output $icoPath
54+
55+
# Function to check if Conda is installed
56+
function Test-CondaInstalled {
57+
try {
58+
& conda --version > $null 2>&1
59+
return $true
60+
} catch {
61+
return $false
62+
}
63+
}
64+
65+
# Check if Conda is installed
66+
if (-Not (Test-CondaInstalled)) {
67+
Write-Host "Conda is not installed."
68+
69+
# Download Miniconda installer if not already downloaded
70+
if (-Not (Test-Path $condaInstallerPath)) {
71+
DownloadFileWithProgress -url $condaInstallerUrl -output $condaInstallerPath
72+
} else {
73+
Write-Host "Miniconda installer already downloaded."
74+
}
75+
76+
# Run the Miniconda installer with messages before and after
77+
Write-Host "Starting Miniconda installation... (there will be no progress bar)"
78+
Start-Process -Wait -FilePath $condaInstallerPath -ArgumentList "/InstallationType=JustMe", "/AddToPath=1", "/RegisterPython=0", "/S", "/D=$condaPath"
79+
Write-Host "Miniconda installation complete."
80+
81+
# Ensure Conda is in the PATH for the current session
82+
$env:Path += ";$condaPath\Scripts;$condaPath"
83+
} else {
84+
Write-Host "Conda is already installed."
85+
}
86+
87+
# Create and activate the Conda environment, and show progress
88+
Write-Host "Creating Conda environment '$envName'..."
89+
& $condaExePath create -n $envName python=$pythonVersion -y
90+
Write-Host "Conda environment '$envName' created."
91+
92+
# Dynamically generate the user's paths for the shortcut
93+
$userCondaScriptsPath = "$condaPath\Scripts"
94+
$userEnvName = $envName
95+
96+
# Create a shortcut on the desktop to activate the environment, install OpenInterpreter, and run it
97+
$targetPath = "$env:SystemRoot\System32\cmd.exe"
98+
$arguments = "/K `"$userCondaScriptsPath\activate.bat` $userEnvName && echo Updating Open Interpreter && pip install -U $packageName && cls && echo Launching Open Interpreter && interpreter`""
99+
100+
$shell = New-Object -ComObject WScript.Shell
101+
$shortcut = $shell.CreateShortcut($desktopPath)
102+
$shortcut.TargetPath = $targetPath
103+
$shortcut.Arguments = $arguments
104+
$shortcut.WorkingDirectory = $env:USERPROFILE
105+
$shortcut.WindowStyle = 1 # Normal window
106+
$shortcut.IconLocation = $icoPath
107+
$shortcut.Save()
108+
109+
Write-Host "Shortcut 'Open Interpreter.lnk' has been created on the desktop with the custom icon."
110+
111+
# Open the shortcut
112+
Start-Process -FilePath $desktopPath

0 commit comments

Comments
 (0)