Skip to content

Commit 08ae9ef

Browse files
committed
enhance justfile for Windows compatibility and cleanup tasks
1 parent 75de8ac commit 08ae9ef

1 file changed

Lines changed: 73 additions & 1 deletion

File tree

justfile

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,67 @@
11
host := if os() == "macos" { "mac" } else if os() == "windows" { "windows" } else { "linux" }
2+
win_arch := if arch() == "aarch64" { "win64_msvc2022_arm64_cross_compiled" } else { "win64_msvc2022_64" }
3+
win_msvc_arch := if arch() == "aarch64" { "arm64" } else { "amd64" }
24
export UV_NO_EDITABLE := "1"
35

6+
set windows-shell := ["powershell.exe", "-NoProfile", "-NoLogo", "-Command"]
7+
48
@_default:
59
@just --list
610

711
# install (re)-build pyqt6-qlementine
12+
[unix]
813
install-pyqt6: _clone install-qt
914
uv sync --group pyqt6 --reinstall-package pyqt6-qlementine
1015

16+
[windows]
17+
install-pyqt6: _clone install-qt
18+
just _vcvars uv sync --group pyqt6 --reinstall-package pyqt6-qlementine
19+
1120
# install (re)-build pyside6-qlementine
21+
[unix]
1222
install-pyside6: _clone (install-qt "6.10.2")
1323
uv sync --group pyside6 --reinstall-package pyside6-qlementine
1424

25+
[windows]
26+
install-pyside6: _clone (install-qt "6.10.2")
27+
just _vcvars uv sync --group pyside6 --reinstall-package pyside6-qlementine
28+
1529
# Clean build artifacts
30+
[unix]
1631
clean:
1732
rm -rf build dist wheelhouse Qt
33+
rm aqtinstall.log
34+
35+
[windows]
36+
clean:
37+
if (Test-Path build) { Remove-Item -Recurse -Force build }
38+
if (Test-Path dist) { Remove-Item -Recurse -Force dist }
39+
if (Test-Path wheelhouse) { Remove-Item -Recurse -Force wheelhouse }
40+
if (Test-Path Qt) { Remove-Item -Recurse -Force Qt }
1841

1942
# run demo widget
2043
demo:
2144
uv run examples/demo.py
2245

2346
# build wheel (into ./wheelhouse)
47+
[unix]
2448
build-wheel target="PyQt6":
2549
#!/usr/bin/env sh
2650
if echo "{{target}}" | grep -qi pyside; then
2751
export QT_VERSION=6.10.2
2852
else
2953
export QT_VERSION=6.8.1
3054
fi
31-
@just install-qt qt_version=$QT_VERSION
55+
just install-qt qt_version=$QT_VERSION
3256
uvx cibuildwheel --config-file pyproject.toml packages/{{target}}-Qlementine
3357

58+
[windows]
59+
build-wheel target="PyQt6":
60+
$qt_version = if ("{{target}}" -match "(?i)pyside") { "6.10.2" } else { "6.8.1" }; \
61+
just install-qt qt_version=$qt_version; \
62+
uvx cibuildwheel --config-file pyproject.toml packages/{{target}}-Qlementine
63+
64+
[unix]
3465
install-qt qt_version="6.8.1":
3566
#!/usr/bin/env sh
3667
if [ -d "Qt/{{ qt_version }}" ]; then
@@ -39,11 +70,20 @@ install-qt qt_version="6.8.1":
3970
uvx --from aqtinstall aqt install-qt {{ host }} desktop {{ qt_version }} --outputdir Qt
4071
fi
4172

73+
[windows]
74+
install-qt qt_version="6.8.1":
75+
if (Test-Path "Qt/{{qt_version}}") { \
76+
Write-Host "Qt {{qt_version}} already installed" \
77+
} else { \
78+
uvx --from aqtinstall aqt install-qt {{host}} desktop {{qt_version}} {{win_arch}} --outputdir Qt \
79+
}
80+
4281
_clone:
4382
git submodule update --init --recursive
4483
@just _patch
4584

4685
# apply local patches to the qlementine submodule
86+
[unix]
4787
_patch:
4888
#!/usr/bin/env sh
4989
root="$(pwd)"
@@ -59,3 +99,35 @@ _patch:
5999
exit 1
60100
fi
61101
done
102+
103+
# run a command inside the MSVC developer environment
104+
[windows]
105+
_vcvars +cmd:
106+
$ErrorActionPreference = 'Stop'; \
107+
$vswhere = Join-Path ([Environment]::GetFolderPath('ProgramFilesX86')) 'Microsoft Visual Studio\Installer\vswhere.exe'; \
108+
if (-not (Test-Path $vswhere)) { throw "vswhere not found at $vswhere — is Visual Studio installed?" }; \
109+
$vsPath = & $vswhere -latest -property installationPath; \
110+
if (-not $vsPath) { throw "No Visual Studio installation found" }; \
111+
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll'); \
112+
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch={{win_msvc_arch}}" *>$null; \
113+
Invoke-Expression "{{cmd}}"
114+
115+
[windows]
116+
_patch:
117+
$root = (Get-Location).Path; \
118+
foreach ($p in Get-ChildItem -Path patches -Filter *.patch -ErrorAction SilentlyContinue) { \
119+
$pPath = $p.FullName; \
120+
$check = git -C qlementine apply --check $pPath 2>&1; \
121+
if ($LASTEXITCODE -eq 0) { \
122+
git -C qlementine apply $pPath; \
123+
Write-Host "Applied $($p.Name)" \
124+
} else { \
125+
$checkR = git -C qlementine apply --check -R $pPath 2>&1; \
126+
if ($LASTEXITCODE -eq 0) { \
127+
Write-Host "Skipping $($p.Name) (already applied)" \
128+
} else { \
129+
Write-Error "ERROR: $($p.Name) conflicts with current submodule state - patch needs updating"; \
130+
exit 1 \
131+
} \
132+
} \
133+
}

0 commit comments

Comments
 (0)