-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
pypi_publish.ps1
66 lines (52 loc) · 1.76 KB
/
pypi_publish.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
# 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))"
# Create and activate virtual environment
& $PYTHON_CMD -m venv venv
. .\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
pip install twine
pip install --upgrade build
Remove-Item ".\dist" -Recurse -Force
python -m build
python -m twine upload dist/*