# run command: maturin --help. if it fails, print the error message and exit
try {
    maturin --help > $null
} catch {
    Write-Error "Failed to run maturin --help: $_"
    exit 1
}


# delete any existing build directory
Remove-Item -Path ./build -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path ./build > $null

# copy ./src/msyrs.pyi to ./msyrs.pyi
Copy-Item -Path ./src/msyrs.pyi -Destination ./msyrs.pyi 

maturin build --release --sdist --out ./build/
$whl = Get-ChildItem -Path ./build/*.whl
# rename the wheel wheel.whl to wheel.zip
Rename-Item -Path $whl -NewName ($whl.BaseName + ".zip")

# delete the pyi file
Remove-Item -Path ./msyrs.pyi