-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
89 lines (66 loc) · 3.46 KB
/
install.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Install script for Windows (install.ps1)
# Check if running as administrator
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "This script requires administrator privileges. Please run it as administrator."
exit 1
}
$latestTag = (Invoke-WebRequest -Uri "https://api.github.com/repos/ecotaxa/cytosense_to_ecotaxa_pipeline/releases/latest" | ConvertFrom-Json).tag_name
$tagWithoutV = $latestTag -replace "^v", ""
$wheelFileName = "cytosense_to_ecotaxa_pipeline-${tagWithoutV}-py3-none-${platformTag}.whl"
$wheelUrl = "https://github.com/ecotaxa/cytosense_to_ecotaxa_pipeline/releases/download/${latestTag}/${wheelFileName}"
# Some debug messages
Write-Host "System architecture: $arch"
Write-Host "Using platform tag: $platformTag"
Write-Host "Latest tag: $latestTag"
Write-Host "Tag without 'v': $tagWithoutV"
Write-Host "Wheel file name: $wheelFileName"
Write-Host "Wheel URL: $wheelUrl"
# Download the wheel file (PowerShell equivalent)
$wheelFile = "$env:TEMP\$wheelFileName"
Write-Host "Downloading wheel from: $wheelUrl"
try {
Invoke-WebRequest -Uri $wheelUrl -OutFile $wheelFile
}
catch {
Write-Error "Error downloading wheel file. Exiting."
exit 1
}
# Check if the file was downloaded successfully (PowerShell equivalent)
if (!(Test-Path $wheelFile)) {
Write-Error "Downloaded file not found: $wheelFile"
exit 1
# Create virtual environment
python -m venv $env:LOCALAPPDATA\cytosense_to_ecotaxa_pipeline_venv
# Activate virtual environment
& "$env:LOCALAPPDATA\cytosense_to_ecotaxa_pipeline_venv\Scripts\Activate.ps1"
# Install Python packages within the virtual environment
# pip install -r requirements.txt
# pip install . # Install the package
pip install $wheelFile
# Create installation directory
$installDir = "$env:ProgramFiles\cytosense_to_ecotaxa_pipeline"
New-Item -ItemType Directory -Path $installDir -Force
# Get Python executable path within the virtual environment
$pythonExec = (Get-Command python).Source
# Get site-packages path dynamically
$sitePackagesPath = & python -c "import site; print(site.getsitepackages()[0])"
# Copy files to the installation directory
# Copy-Item -Path "$sitePackagesPath\cytosense_to_ecotaxa_pipeline\bin\Cyz2Json.exe" -Destination "$installDir\Cyz2Json.exe"
Copy-Item -Path "$sitePackagesPath\cytosense_to_ecotaxa_pipeline\bin" -Destination "$installDir\bin" -Recurse -Force
Copy-Item -Path "$sitePackagesPath\cytosense_to_ecotaxa_pipeline\pipeline.py" -Destination "$installDir\pipeline.py"
Copy-Item -Path "$sitePackagesPath\cytosense_to_ecotaxa_pipeline\main.py" -Destination "$installDir\main.py"
# Create executable wrappers (using batch files for simplicity)
# Cyz2Json.bat
@"
@echo off
"$env:LOCALAPPDATA\cytosense_to_ecotaxa_pipeline_venv\Scripts\python.exe" "$installDir\pipeline.py" %*
"@ | Out-File -Encoding ascii "$installDir\cytosense_to_ecotaxa_pipeline.bat"
# Add installation directory to PATH
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "Machine")
if (-not ($currentPath -like "*$installDir*")) {
[Environment]::SetEnvironmentVariable("PATH", "$installDir;$currentPath", "Machine")
Write-Host "Added '$installDir' to the system PATH. You may need to restart your PowerShell session or log out and back in for this change to take effect."
}
# Deactivate virtual environment
deactivate
Write-Host "Installation complete."