Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
ci:
uses: nanvix/workflows/.github/workflows/nanvix-ci.yml@v2.0.1
with:
zutil-version: "v0.8.2"
zutil-version: "v0.8.5"
platforms: "[\"microvm\"]"
process-modes: "[\"standalone\"]"
memory-sizes: "[\"256mb\"]"
Expand All @@ -39,7 +39,7 @@
yaml-paths: ".github/workflows/ci.yml"
release-notes-extra: |
CPython 3.12.3 distribution for Nanvix with pure Python pip packages.
docker-image: "ghcr.io/nanvix/toolchain-python@sha256:2ef7213bfff85e927f18d8f0fc53063b9c6ffed236a6b30c92f6b4e148c2dec4" # yamllint disable-line rule:line-length

Check warning on line 42 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / ci / Format & Lint

42:127 [comments] too few spaces before comment
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
DISPATCH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .nanvix/nanvix.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nanvix-python"
version = "3.12.3"
nanvix-version = "0.12.547"
nanvix-version = "0.13.16"

[builds]
[builds.matrix]
Expand Down
336 changes: 168 additions & 168 deletions z.ps1
Original file line number Diff line number Diff line change
@@ -1,168 +1,168 @@
# Copyright(c) The Maintainers of Nanvix.
# Licensed under the MIT License.
# Thin wrapper that delegates to the nanvix-zutil CLI.
# Self-bootstraps nanvix-zutil into .nanvix\venv\ if it is not already installed.
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$ZArgs
)
$ErrorActionPreference = 'Stop'
$zutilVersion = if ($env:NANVIX_ZUTIL_VERSION) {
$env:NANVIX_ZUTIL_VERSION
}
else {
"0.8.2"
}
$zutilVersion = $zutilVersion -replace "^v", ""
# z.ps1 lives at the repository root, so use its directory directly
# instead of relying on git to discover the top-level checkout directory.
$repoRoot = $PSScriptRoot
$venvDir = Join-Path $repoRoot ".nanvix\venv"
$venvPython = Join-Path $venvDir "Scripts\python.exe"
$venvZutil = Join-Path $venvDir "Scripts\nanvix-zutil.exe"
# Windows compatibility shim: nanvix-zutil references os.getuid/os.getgid
# which are unavailable on Windows. Stub them before importing the package.
# NOTE: Use single quotes inside the Python code so that PowerShell does not
# strip the quotes when passing the string to python.exe -c.
$ShimCode = @'
import os,sys;os.getuid=getattr(os,'getuid',lambda:0);os.getgid=getattr(os,'getgid',lambda:0);from nanvix_zutil.__main__ import main;sys.exit(main())
'@
$zutilGlobalVersion = try {
& nanvix-zutil --version 2>$null
}
catch {
$null
}
function Bootstrap {
# Pin nanvix-zutil version for reproducible bootstrapping.
# Override with NANVIX_ZUTIL_VERSION env var if needed.
Write-Information "nanvix-zutil not found -- bootstrapping nanvix-zutil==${zutilVersion}..." -InformationAction Continue
$wheelUrl = "https://github.com/nanvix/zutils/releases/download/v${zutilVersion}/nanvix_zutil-${zutilVersion}-py3-none-any.whl"
# Discover a Python 3 interpreter.
$venvArgs = @("-m", "venv")
if (Test-Path $venvDir) {
$venvArgs += "--clear"
}
$venvArgs += $venvDir
if (Get-Command py -ErrorAction SilentlyContinue) {
& py -3 @venvArgs
}
elseif (Get-Command python -ErrorAction SilentlyContinue) {
& python @venvArgs
}
elseif (Get-Command python3 -ErrorAction SilentlyContinue) {
& python3 @venvArgs
}
else {
throw "Python 3 not found. Install Python 3 and ensure py, python, or python3 is on PATH."
}
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
throw "venv creation failed (exit code $LASTEXITCODE)"
}
& $venvPython -m pip install --quiet "nanvix-zutil[lint] @ $($wheelUrl)"
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
throw "pip install failed (exit code $LASTEXITCODE)"
}
}
# Prefer the venv copy if it exists; otherwise use the global install.
$bin = $null
if ((-not (Test-Path $venvDir)) -and (-not $zutilGlobalVersion)) {
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
$bin = $venvZutil
}
elseif (Test-Path $venvZutil) {
# Use the shim to check version -- running the exe directly fails on
# Windows because os.getuid/os.getgid are unavailable (see FIXME above).
$venvVersion = try {
& $venvPython -c $ShimCode --version 2>$null
}
catch {
$null
}
if ($venvVersion -ne "nanvix-zutil ${zutilVersion}") {
Write-Warning "Venv nanvix-zutil version mismatch. Expected ${zutilVersion}, found ${venvVersion}. Re-bootstrapping..."
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
}
$bin = $venvZutil
}
elseif ((Test-Path $venvDir) -and (-not $zutilGlobalVersion)) {
Write-Warning "Incomplete venv detected (binary missing). Re-running bootstrap..."
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
$bin = $venvZutil
}
else {
$bin = "nanvix-zutil"
if ($zutilGlobalVersion -ne "nanvix-zutil ${zutilVersion}") {
Write-Warning "nanvix-zutil global install does not match expected version. Expected ${zutilVersion}, found ${zutilGlobalVersion}."
}
}
# Extract --with-nanvix PATH before forwarding to nanvix-zutil.
$filteredArgs = [System.Collections.Generic.List[string]]::new()
$i = 0
while ($i -lt $ZArgs.Count) {
if ($ZArgs[$i] -eq '--with-nanvix') {
if ($i + 1 -ge $ZArgs.Count) {
throw "ERROR: --with-nanvix requires a path argument"
}
$item = Get-Item -LiteralPath $ZArgs[$i + 1] -ErrorAction Stop
if (-not $item.PSIsContainer) {
throw "ERROR: --with-nanvix path is not a directory: $($ZArgs[$i + 1])"
}
$env:WITH_NANVIX = $item.FullName
$i += 2
}
elseif ($ZArgs[$i] -match '^--with-nanvix=(.+)$') {
$item = Get-Item -LiteralPath $Matches[1] -ErrorAction Stop
if (-not $item.PSIsContainer) {
throw "ERROR: --with-nanvix path is not a directory: $($Matches[1])"
}
$env:WITH_NANVIX = $item.FullName
$i++
}
else {
$filteredArgs.Add($ZArgs[$i])
$i++
}
}
$filteredArray = $filteredArgs.ToArray()
if ($bin -eq $venvZutil) {
& $venvPython -c $ShimCode @filteredArray
}
else {
& $bin @filteredArray
}
$ec = $LASTEXITCODE
# On Windows the venv's python.exe is locked while it runs, so the Python
# distclean command cannot delete it. Now that the interpreter has exited the
# lock is released and the shell can safely remove the venv directory.
if ($filteredArray -and $filteredArray[0] -eq "distclean" -and (Test-Path $venvDir)) {
Remove-Item $venvDir -Recurse -Force -ErrorAction SilentlyContinue
}
exit $ec
# Copyright(c) The Maintainers of Nanvix.
# Licensed under the MIT License.

# Thin wrapper that delegates to the nanvix-zutil CLI.
# Self-bootstraps nanvix-zutil into .nanvix\venv\ if it is not already installed.

param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$ZArgs
)

$ErrorActionPreference = 'Stop'

$zutilVersion = if ($env:NANVIX_ZUTIL_VERSION) {
$env:NANVIX_ZUTIL_VERSION
}
else {
"0.8.5"
}
$zutilVersion = $zutilVersion -replace "^v", ""

# z.ps1 lives at the repository root, so use its directory directly
# instead of relying on git to discover the top-level checkout directory.
$repoRoot = $PSScriptRoot
$venvDir = Join-Path $repoRoot ".nanvix\venv"
$venvPython = Join-Path $venvDir "Scripts\python.exe"
$venvZutil = Join-Path $venvDir "Scripts\nanvix-zutil.exe"

# Windows compatibility shim: nanvix-zutil references os.getuid/os.getgid
# which are unavailable on Windows. Stub them before importing the package.
# NOTE: Use single quotes inside the Python code so that PowerShell does not
# strip the quotes when passing the string to python.exe -c.
$ShimCode = @'
import os,sys;os.getuid=getattr(os,'getuid',lambda:0);os.getgid=getattr(os,'getgid',lambda:0);from nanvix_zutil.__main__ import main;sys.exit(main())
'@

$zutilGlobalVersion = try {
& nanvix-zutil --version 2>$null
}
catch {
$null
}

function Bootstrap {
# Pin nanvix-zutil version for reproducible bootstrapping.
# Override with NANVIX_ZUTIL_VERSION env var if needed.
Write-Information "nanvix-zutil not found -- bootstrapping nanvix-zutil==${zutilVersion}..." -InformationAction Continue

$wheelUrl = "https://github.com/nanvix/zutils/releases/download/v${zutilVersion}/nanvix_zutil-${zutilVersion}-py3-none-any.whl"

# Discover a Python 3 interpreter.
$venvArgs = @("-m", "venv")
if (Test-Path $venvDir) {
$venvArgs += "--clear"
}
$venvArgs += $venvDir

if (Get-Command py -ErrorAction SilentlyContinue) {
& py -3 @venvArgs
}
elseif (Get-Command python -ErrorAction SilentlyContinue) {
& python @venvArgs
}
elseif (Get-Command python3 -ErrorAction SilentlyContinue) {
& python3 @venvArgs
}
else {
throw "Python 3 not found. Install Python 3 and ensure py, python, or python3 is on PATH."
}
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
throw "venv creation failed (exit code $LASTEXITCODE)"
}
& $venvPython -m pip install --quiet "nanvix-zutil[lint] @ $($wheelUrl)"
if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {
throw "pip install failed (exit code $LASTEXITCODE)"
}
}

# Prefer the venv copy if it exists; otherwise use the global install.
$bin = $null
if ((-not (Test-Path $venvDir)) -and (-not $zutilGlobalVersion)) {
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
$bin = $venvZutil
}
elseif (Test-Path $venvZutil) {
# Use the shim to check version -- running the exe directly fails on
# Windows because os.getuid/os.getgid are unavailable (see FIXME above).
$venvVersion = try {
& $venvPython -c $ShimCode --version 2>$null
}
catch {
$null
}
if ($venvVersion -ne "nanvix-zutil ${zutilVersion}") {
Write-Warning "Venv nanvix-zutil version mismatch. Expected ${zutilVersion}, found ${venvVersion}. Re-bootstrapping..."
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
}
$bin = $venvZutil
}
elseif ((Test-Path $venvDir) -and (-not $zutilGlobalVersion)) {
Write-Warning "Incomplete venv detected (binary missing). Re-running bootstrap..."
Bootstrap
if (-not (Test-Path $venvZutil)) {
throw "Bootstrap completed but $venvZutil not found."
}
$bin = $venvZutil
}
else {
$bin = "nanvix-zutil"
if ($zutilGlobalVersion -ne "nanvix-zutil ${zutilVersion}") {
Write-Warning "nanvix-zutil global install does not match expected version. Expected ${zutilVersion}, found ${zutilGlobalVersion}."
}
}

# Extract --with-nanvix PATH before forwarding to nanvix-zutil.
$filteredArgs = [System.Collections.Generic.List[string]]::new()
$i = 0
while ($i -lt $ZArgs.Count) {
if ($ZArgs[$i] -eq '--with-nanvix') {
if ($i + 1 -ge $ZArgs.Count) {
throw "ERROR: --with-nanvix requires a path argument"
}
$item = Get-Item -LiteralPath $ZArgs[$i + 1] -ErrorAction Stop
if (-not $item.PSIsContainer) {
throw "ERROR: --with-nanvix path is not a directory: $($ZArgs[$i + 1])"
}
$env:WITH_NANVIX = $item.FullName
$i += 2
}
elseif ($ZArgs[$i] -match '^--with-nanvix=(.+)$') {
$item = Get-Item -LiteralPath $Matches[1] -ErrorAction Stop
if (-not $item.PSIsContainer) {
throw "ERROR: --with-nanvix path is not a directory: $($Matches[1])"
}
$env:WITH_NANVIX = $item.FullName
$i++
}
else {
$filteredArgs.Add($ZArgs[$i])
$i++
}
}

$filteredArray = $filteredArgs.ToArray()

if ($bin -eq $venvZutil) {
& $venvPython -c $ShimCode @filteredArray
}
else {
& $bin @filteredArray
}

$ec = $LASTEXITCODE

# On Windows the venv's python.exe is locked while it runs, so the Python
# distclean command cannot delete it. Now that the interpreter has exited the
# lock is released and the shell can safely remove the venv directory.
if ($filteredArray -and $filteredArray[0] -eq "distclean" -and (Test-Path $venvDir)) {
Remove-Item $venvDir -Recurse -Force -ErrorAction SilentlyContinue
}

exit $ec
2 changes: 1 addition & 1 deletion z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set -euo pipefail

PINNED_VERSION="0.8.2"
PINNED_VERSION="0.8.5"
RAW_ZUTIL_VERSION="${NANVIX_ZUTIL_VERSION:-$PINNED_VERSION}"
ZUTIL_VERSION="${RAW_ZUTIL_VERSION#v}"
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
Expand Down
Loading