-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
setup_and_run.ps1
58 lines (47 loc) · 1.62 KB
/
setup_and_run.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
# Function to check and return the available Python command
function Get-PythonCommand {
$commands = @('python3', 'python')
foreach ($cmd in $commands) {
$version = & $cmd --version 2>&1
if ($version -match "Python 3.") {
return $cmd
}
}
Write-Host "Python 3 is not installed."
exit
}
# Check if npm is available
$npmCmd = Get-Command npm -ErrorAction SilentlyContinue
if ($null -ne $npmCmd) {
$NPM_CMD = "npm"
} else {
Write-Host "Node is not installed."
Exit 1
}
# Install dependencies and build the project
cd ".\frontend\palworld-pal-editor-webui"
& $NPM_CMD install
& $NPM_CMD run build
cd "..\..\"
# Move the build directory
Remove-Item ".\src\palworld_pal_editor\webui" -Recurse -Force
New-Item -Path ".\src\palworld_pal_editor\webui" -ItemType "directory"
Move-Item -Path ".\frontend\palworld-pal-editor-webui\dist\*" -Destination ".\src\palworld_pal_editor\webui" -Force
# Determine the appropriate Python command
$PYTHON_CMD = Get-PythonCommand
# Check Python version
$versionOutput = & $PYTHON_CMD --version 2>&1
$versionNumbers = $versionOutput -replace "Python ", "" -split "\."
$majorVersion = [int]$versionNumbers[0]
$minorVersion = [int]$versionNumbers[1]
# Ensure Python version is at least 3.11
if ($majorVersion -lt 3 -or ($majorVersion -eq 3 -and $minorVersion -lt 11)) {
Write-Host "Python version 3.11 or newer is required."
exit
}
Write-Host "Using $($PYTHON_CMD) (version $($majorVersion).$($minorVersion))"
& $PYTHON_CMD -m venv venv
. .\venv\Scripts\Activate.ps1
pip install -r requirements.txt
pip install -e .
python -m palworld_pal_editor $args