-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.ps1
70 lines (64 loc) · 2.26 KB
/
setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Check if a command exists
function Test-CommandExists {
param (
[string]$Command
)
$exists = $null -ne (Get-Command $Command -ErrorAction SilentlyContinue)
return $exists
}
# Install Python on Windows
function Install-PythonWindows {
Write-Host "Attempting to install Python 3.11..."
# Python installation on Windows should be done manually or through an installer
Write-Host "Please install Python 3.11 manually from the official website."
exit
}
# 1. Check if Python is installed
if (-not (Test-CommandExists "python") -and -not (Test-CommandExists "python3")) {
Write-Host "Python is not installed. Attempting to install..."
Install-PythonWindows
# Recheck if Python is installed
if (-not (Test-CommandExists "python") -and -not (Test-CommandExists "python3")) {
Write-Host "Python installation failed. Please install Python manually."
exit
}
} else {
Write-Host "Python is already installed."
}
# 2. Check if Flutter is installed
if (-not (Test-CommandExists "flutter")) {
Write-Host "Warning: If you want to build the GUI, you might need Flutter (optionally)."
}
# 3. Install requirements using pip
try {
pip install -r requirements.txt -ErrorAction Stop
} catch {
try {
pip3 install -r requirements.txt -ErrorAction Stop
} catch {
Write-Host "Failed to install requirements with pip and pip3. Attempting to install pip..."
python -m ensurepip
if ($LASTEXITCODE -ne 0) {
python3 -m ensurepip
}
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to install pip. Please reinstall Python manually."
exit
}
pip install -r requirements.txt
}
}
# 4. Download spacy model
try {
python -m spacy download en_core_web_sm -ErrorAction Stop
} catch {
python3 -m spacy download en_core_web_sm
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to download spacy model. Please check your Python installation."
exit
}
}
# 5. Inform the user about the next steps
Write-Host "To use the CLI, run the following command from the current directory:"
Write-Host "python bionicpython/bionicpython.py '<path to your pdf/docx file>'"
Write-Host "Remember to insert the path in quotes if it isn't already."