mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
streamline pype installation, updated tools
This commit is contained in:
parent
ade80265e7
commit
5e06361968
17 changed files with 447 additions and 184 deletions
|
|
@ -21,22 +21,21 @@ function Exit-WithCode($exitcode) {
|
|||
|
||||
exit $exitcode
|
||||
}
|
||||
|
||||
|
||||
function Show-PSWarning() {
|
||||
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
||||
Write-Host "!!! " -NoNewline -ForegroundColor Red
|
||||
Write-Host "You are using old version of PowerShell. $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
|
||||
Write-Host "Please update to at least 7.0 - " -NoNewline -ForegroundColor Gray
|
||||
Write-Host "https://github.com/PowerShell/PowerShell/releases" -ForegroundColor White
|
||||
Exit-WithCode 1
|
||||
}
|
||||
}
|
||||
$current_dir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||
$pype_root = (Get-Item $current_dir).parent.FullName
|
||||
|
||||
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
||||
Write-Host "!!! " -NoNewline -ForegroundColor Red
|
||||
Write-Host "You are using old version of PowerShell. $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
|
||||
Write-Host "Please update to at least 7.0 - https://github.com/PowerShell/PowerShell/releases"
|
||||
Exit-WithCode 1
|
||||
}
|
||||
|
||||
$arguments=$ARGS
|
||||
if($arguments -eq "--skip-venv") {
|
||||
$skip_venv=$true
|
||||
}
|
||||
|
||||
$art = @'
|
||||
$art = @"
|
||||
|
||||
|
||||
____________
|
||||
|
|
@ -47,10 +46,13 @@ $art = @'
|
|||
\ \____\ \ \_____\ \__\\__\\__\
|
||||
\/____/ \/_____/ . PYPE Club .
|
||||
|
||||
'@
|
||||
"@
|
||||
|
||||
Write-Host $art -ForegroundColor DarkGreen
|
||||
|
||||
# Enable if PS 7.x is needed.
|
||||
# Show-PSWarning
|
||||
|
||||
$version_file = Get-Content -Path "$($pype_root)\pype\version.py"
|
||||
$result = [regex]::Matches($version_file, '__version__ = "(?<version>\d+\.\d+.\d+)"')
|
||||
$pype_version = $result[0].Groups['version'].Value
|
||||
|
|
@ -85,42 +87,30 @@ if(($matches[1] -lt 3) -or ($matches[2] -lt 7)) {
|
|||
}
|
||||
Write-Host "OK [ $p ]" -ForegroundColor green
|
||||
|
||||
Write-Host "--- " -NoNewline -ForegroundColor yellow
|
||||
Write-Host "Cleaning venv directory ..."
|
||||
Remove-Item -Recurse -Force "$($pype_root)\venv\*"
|
||||
|
||||
if ($skip_venv -ne $true) {
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Creating virtual env ..."
|
||||
& python -m venv venv
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Entering venv ..."
|
||||
try {
|
||||
. (".\venv\Scripts\Activate.ps1")
|
||||
}
|
||||
catch {
|
||||
Write-Host "!!! Failed to activate" -ForegroundColor red
|
||||
Write-Host $_.Exception.Message
|
||||
Exit-WithCode 1
|
||||
}
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Updating pip ..."
|
||||
& python -m pip install --upgrade pip
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Installing packages to new venv ..."
|
||||
& pip install -r .\requirements.txt
|
||||
} else {
|
||||
Write-Host "*** " -NoNewline -ForegroundColor yellow
|
||||
Write-Host "Skipping creaton of venv ..."
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Entering venv ..."
|
||||
try {
|
||||
. (".\venv\Scripts\Activate.ps1")
|
||||
}
|
||||
catch {
|
||||
Write-Host "!!! Failed to activate" -ForegroundColor red
|
||||
Write-Host $_.Exception.Message
|
||||
Exit-WithCode 1
|
||||
}
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Creating virtual env ..."
|
||||
& python -m venv venv
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Entering venv ..."
|
||||
try {
|
||||
. (".\venv\Scripts\Activate.ps1")
|
||||
}
|
||||
catch {
|
||||
Write-Host "!!! Failed to activate" -ForegroundColor red
|
||||
Write-Host $_.Exception.Message
|
||||
Exit-WithCode 1
|
||||
}
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Updating pip ..."
|
||||
& python -m pip install --upgrade pip
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Installing packages to new venv ..."
|
||||
& pip install -r "$($pype_root)\requirements.txt"
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Cleaning cache files ... " -NoNewline
|
||||
|
|
@ -128,21 +118,6 @@ Get-ChildItem "$($pype_root)" -Filter "*.pyc" -Force -Recurse | Remove-Item -For
|
|||
Get-ChildItem "$($pype_root)" -Filter "__pycache__" -Force -Recurse | Remove-Item -Force -Recurse
|
||||
Write-Host "OK" -ForegroundColor green
|
||||
|
||||
# store original PYTHONPATH
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Storing original PYTHONPATH ... " -NoNewline
|
||||
$original_pythonpath = $env:PYTHONPATH
|
||||
Write-Host "OK" -ForegroundColor green
|
||||
$new_pythonpath = Get-ChildItem -Directory -Path .\ | Microsoft.PowerShell.Utility\Join-String -Property FullName -DoubleQuote -Separator ';'
|
||||
$env:PYTHONPATH = $env:PYTHONPATH + ";" + $new_pythonpath
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Adding repos to PYTHONPATH ..."
|
||||
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Building Pype ..."
|
||||
& python setup.py build
|
||||
Write-Host ">>> " -NoNewline -ForegroundColor green
|
||||
Write-Host "Restoring original PYTHONPATH ... " -NoNewline
|
||||
$env:PYTHONPATH = $original_pythonpath
|
||||
Write-Host "OK" -ForegroundColor green
|
||||
Write-Host "Deactivating venv ..."
|
||||
deactivate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue