forked from gavanderhoorn/rossum
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update install shell script options to not update environment variabl…
…es during install
- Loading branch information
1 parent
b35cbe8
commit 582476d
Showing
2 changed files
with
65 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,95 @@ | ||
param( | ||
[string]$penv, | ||
[switch]$SetEnvVariables # Optional switch to set environment variables | ||
) | ||
|
||
function ktransw_install { | ||
Write-Output "Installing ktransw ..." | ||
|
||
#install python dependencies | ||
# Install Python dependencies | ||
pip3 install -r .\deps\ktransw\requirements.txt | ||
|
||
#add ktransw to path | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\deps\ktransw\bin;$PSScriptRoot\deps\ktransw\deps\gpp" | ||
Write-Output "Added to Path: $PSScriptRoot\deps\ktransw\bin" | ||
Write-Output "Added to Path: $PSScriptRoot\deps\ktransw\deps\gpp" | ||
|
||
# Add ktransw to PATH | ||
if ($SetEnvVariables) { | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\deps\ktransw\bin;$PSScriptRoot\deps\ktransw\deps\gpp" | ||
Write-Output "Added to PATH: $PSScriptRoot\deps\ktransw\bin" | ||
Write-Output "Added to PATH: $PSScriptRoot\deps\ktransw\deps\gpp" | ||
} else { | ||
Write-Output "Skipping adding to ktransw" | ||
} | ||
} | ||
|
||
function yaml_install { | ||
Write-Output "Installing yamljson2xml ..." | ||
cd "$PSScriptRoot\deps\yamljson2xml" | ||
Push-Location "$PSScriptRoot\deps\yamljson2xml" | ||
python -m pip install . | ||
cd "$PSScriptRoot" | ||
|
||
#add ktransw to path | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\deps\yamljson2xml\src" | ||
Write-Output "Added to Path: $PSScriptRoot\deps\yamljson2xml\src" | ||
|
||
Pop-Location | ||
|
||
# Add yamljson2xml to PATH | ||
if ($SetEnvVariables) { | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\deps\yamljson2xml\src" | ||
Write-Output "Added to PATH: $PSScriptRoot\deps\yamljson2xml\src" | ||
} else { | ||
Write-Output "Skipping adding yamljson2xml to path" | ||
} | ||
} | ||
|
||
function rossum_install { | ||
Write-Output "Installing rossum ..." | ||
|
||
#install python dependencies | ||
# Install Python dependencies | ||
pip3 install -r requirements.txt | ||
|
||
#add ktransw to path | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\bin" | ||
Write-Output "Added to Path: $PSScriptRoot\bin" | ||
|
||
#add environment variables | ||
[Environment]::SetEnvironmentVariable("ROSSUM_CORE_VERSION", "V910-1", "User"); | ||
[Environment]::SetEnvironmentVariable("ROSSUM_PKG_PATH", "", "User"); | ||
[Environment]::SetEnvironmentVariable("ROSSUM_SERVER_IP", "127.0.0.1", "User"); | ||
# Add rossum to PATH | ||
if ($SetEnvVariables) { | ||
$global:NEWPATH = $global:NEWPATH + ";$PSScriptRoot\bin" | ||
Write-Output "Added to PATH: $PSScriptRoot\bin" | ||
} else { | ||
Write-Output "Skipping adding rossum to path" | ||
} | ||
|
||
# Set environment variables if the switch is provided | ||
if ($SetEnvVariables) { | ||
Write-Output "Setting environment variables..." | ||
[Environment]::SetEnvironmentVariable("ROSSUM_CORE_VERSION", "V910-1", "User") | ||
[Environment]::SetEnvironmentVariable("ROSSUM_PKG_PATH", "", "User") | ||
[Environment]::SetEnvironmentVariable("ROSSUM_SERVER_IP", "127.0.0.1", "User") | ||
} else { | ||
Write-Output "Skipping setting rossum environment variables." | ||
} | ||
} | ||
|
||
|
||
#python environment | ||
$penv=$args[0] | ||
|
||
# Activate Python environment if provided | ||
if ($penv) { | ||
$pactivate = $penv + "\Scripts\Activate.ps1" | ||
Write-Output $pactivate | ||
Invoke-Expression -Command $pactivate | ||
$pactivate = Join-Path $penv "Scripts\Activate.ps1" | ||
Write-Output "Activating Python environment: $pactivate" | ||
& $pactivate | ||
} | ||
|
||
#get environment path | ||
$OLDPATH = [System.Environment]::GetEnvironmentVariable('PATH','User') | ||
# Get current PATH environment variable | ||
$OLDPATH = [System.Environment]::GetEnvironmentVariable('PATH', 'User') | ||
$global:NEWPATH = $OLDPATH | ||
|
||
#run ktransw install | ||
# Run installations | ||
ktransw_install | ||
|
||
#run yamljson2xml install | ||
yaml_install | ||
|
||
#run rossum install | ||
rossum_install | ||
|
||
#set Path | ||
[Environment]::SetEnvironmentVariable("PATH", "$global:NEWPATH", "User") | ||
# Update PATH environment variable | ||
if ($SetEnvVariables) { | ||
[Environment]::SetEnvironmentVariable("PATH", "$global:NEWPATH", "User") | ||
Write-Output "Updated PATH environment variable." | ||
} else { | ||
Write-Output "Skipping setting environment variables." | ||
} | ||
|
||
# Deactivate Python environment if activated | ||
if ($penv) { | ||
$pdeactivate = $penv + "\Scripts\deactivate" | ||
deactivate | ||
$pdeactivate = Join-Path $penv "Scripts\deactivate.ps1" | ||
if (Test-Path $pdeactivate) { | ||
Write-Output "Deactivating Python environment: $pdeactivate" | ||
& $pdeactivate | ||
} else { | ||
Write-Output "Deactivate script not found." | ||
} | ||
} | ||
|