File size: 986 Bytes
21ff762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
param(
    [Parameter(ValueFromRemainingArguments = $true)]
    [string[]]$RemainingArgs
)

$ErrorActionPreference = "Stop"

$CtxDir = $PSScriptRoot
$ForwardArgs = @()

if ($RemainingArgs.Count -ge 2 -and $RemainingArgs[0] -eq "--ctx-dir") {
    $CtxDir = $RemainingArgs[1]
    if ($RemainingArgs.Count -gt 2) {
        $ForwardArgs = $RemainingArgs[2..($RemainingArgs.Count - 1)]
    }
}
elseif ($RemainingArgs.Count -ge 1 -and -not $RemainingArgs[0].StartsWith("--")) {
    $CtxDir = $RemainingArgs[0]
    if ($RemainingArgs.Count -gt 1) {
        $ForwardArgs = $RemainingArgs[1..($RemainingArgs.Count - 1)]
    }
}
else {
    $ForwardArgs = $RemainingArgs
}

$Python = $env:PYTHON
if (-not $Python) {
    $Python = "python"
}

$SrcDir = Join-Path $CtxDir "src"
$Separator = [System.IO.Path]::PathSeparator
if ($env:PYTHONPATH) {
    $env:PYTHONPATH = "$SrcDir$Separator$env:PYTHONPATH"
}
else {
    $env:PYTHONPATH = $SrcDir
}

& $Python -m ctx_init @ForwardArgs
exit $LASTEXITCODE