-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_pyapp_example.ps1
41 lines (36 loc) · 1.61 KB
/
build_pyapp_example.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
# This is supposed to be executed in the root of the project
# The executable will execute this function when it starts
$env:PYAPP_EXEC_SPEC=''
$env:PYAPP_EXEC_MODULE=''
$env:PYAPP_EXEC_NOTEBOOK=''
$env:PYAPP_EXEC_SCRIPT="$((Get-Item -Path "./src/pyapp_notebook/example.py").FullName)"
$executable_name = "pyapp_example"
# We are building the wheel with poetry
if (Test-Path -Path "./dist") {
Remove-Item -Path ./dist -Recurse -Force
}
rye build
# Get the full path of the wheel file in the dist directory
$wheel_file = (Get-Item -Path "./dist/*.whl").FullName
# Print wheel file path
Write-Host "Wheel file path: $wheel_file"
$env:PYAPP_PROJECT_PATH=$wheel_file
# if check if pyapp-latest folder not exists
if (!(Test-Path -Path "./pyapp-latest")) {
# Download the zip file from the URL
Invoke-WebRequest https://github.com/quinnhornblow/pyapp/releases/latest/download/source.zip -OutFile pyapp-source.zip
# Extract the zip file to the temporary folder using Expand-Archive
Expand-Archive -Path ./pyapp-source.zip -DestinationPath .
# Move the extracted folder to the desired location and rename it
Move-Item -Path ./pyapp-v* -Destination ./pyapp-latest
Remove-Item -Path ./pyapp-source.zip
}
# Change the current directory to the extracted folder
Set-Location -Path ./pyapp-latest
cargo build --release
# Move Item and rename it to $env:PYAPP_PROJECT_NAME.exe, overwrite if exists
Move-Item target\release\pyapp.exe ..\$executable_name.exe -Force
# Change the current directory to the root of the project
Set-Location -Path ..
# Remove the pyapp-latest folder
Remove-Item -Path ./pyapp-latest -Recurse -Force