Skip to content

Commit a606844

Browse files
committed
Add raygeo build tooling
- Add scripts/build-raygeo.sh for maturin wheel build/install - Add raygeo-build, raygeo-check, raygeo-test pixi tasks - Bump raygeo dependency to >=0.2.0 - Add patchelf to native dependencies - Document raygeo section in AGENTS.md
1 parent d864bfd commit a606844

5 files changed

Lines changed: 113 additions & 36 deletions

File tree

AGENTS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
o `pixi run test`: Run backend tests
99
o `pixi run uitest`: Run UI tests
1010
o `pixi run lint`. Performs linting and static code analysis
11+
o `pixi run raygeo-check`: Check Raygeo changes before compilation
12+
o `pixi run raygeo-build`: Build and install the raygeo Rust extension
13+
o `pixi run raygeo-test`: Run raygeo tests
1114
o `pixi run print-untranslated list`: List languages with untranslated strings
1215
o `pixi run print-untranslated <lang>`: Print untranslated strings from po file
1316

@@ -18,6 +21,12 @@
1821
- Never mark your changes with inline comments. Code is for clean, final implementation only
1922
- Retain exiting formatting, docstrings, and comments
2023

24+
## Raygeo (Rust/PyO3 geometry library)
25+
26+
- Location: a separate repository in `external/raygeo/` that you may also edit
27+
- All commands must be run via pixi from the workspace root
28+
- The pixi environment includes `maturin`, `cargo`, and `rustc` — never install these separately
29+
2130
## Other rules
2231

2332
- Do not run the full test suite prematurely. Fix all linter errors first. Run targeted tests.

pixi.lock

Lines changed: 48 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ PyOpenGL-accelerate = "==3.1.10"
3131
PyGObject = "==3.50.0"
3232
pkg-config = "*"
3333
rust = "*"
34+
patchelf = "*"
3435

3536
[feature.app.pypi-dependencies]
36-
raygeo = "==0.1.9"
37+
raygeo = ">=0.2.0"
3738
rayforge = { editable = true, path = "." }
3839
aiohttp = "==3.13.5"
3940
asyncudp = "==0.11.0"
@@ -144,6 +145,15 @@ cmd = "scripts/with_gdk.sh scripts/screenshot/cli.py"
144145
cmd = "python3 -m build"
145146
depends-on = ["compile-translations"]
146147

148+
[tasks.raygeo-build]
149+
cmd = "bash scripts/build-raygeo.sh"
150+
151+
[tasks.raygeo-check]
152+
cmd = "cargo check --manifest-path external/raygeo/Cargo.toml"
153+
154+
[tasks.raygeo-test]
155+
cmd = "cargo test --manifest-path external/raygeo/crates/raygeo/Cargo.toml && pytest -v external/raygeo/tests/"
156+
147157
[tasks.build-deb]
148158
# Builds a binary .deb package for local installation and testing.
149159
cmd = "bash scripts/build-deb.sh"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
raygeo==0.1.9
1+
raygeo>=0.2.0
22
aiohttp==3.13.5
33
asyncudp==0.11.0
44
blinker==1.9.0

scripts/build-raygeo.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
RAYGEO_DIR="external/raygeo"
5+
PYPROJECT="$RAYGEO_DIR/pyproject.toml"
6+
7+
# Derive PEP 440 version from git describe.
8+
# Use .postN so the version sorts HIGHER than the PyPI release, ensuring
9+
# that uv/pip treats it as an upgrade over the published package.
10+
# Example: v0.2.0-1-gb7e8413 -> 0.2.0.post1+gb7e8413
11+
RAW=$(git -C "$RAYGEO_DIR" describe --tags --long --abbrev=7 2>/dev/null) || {
12+
echo "Error: No git tags found in $RAYGEO_DIR" >&2
13+
exit 1
14+
}
15+
PEP440=$(echo "$RAW" | sed -e 's/^v//' -e 's/-\([0-9]*\)-g/.post\1+g/')
16+
17+
echo "Building raygeo wheel with version: $PEP440"
18+
19+
# Temporarily set the version in pyproject.toml for maturin to pick up.
20+
# pyproject.toml takes precedence over Cargo.toml for maturin.
21+
sed -i "s/^dynamic = \[\"version\"\]/version = \"$PEP440\"/" "$PYPROJECT"
22+
23+
# Restore on exit (even on failure).
24+
restore() {
25+
sed -i "s/^version = \"$PEP440\"/dynamic = [\"version\"]/" "$PYPROJECT"
26+
}
27+
trap restore EXIT
28+
29+
rm -rf "$RAYGEO_DIR/target"
30+
mkdir -p "$RAYGEO_DIR/target/wheels"
31+
touch "$RAYGEO_DIR/target/wheels/.gitkeep"
32+
maturin build --manifest-path "$RAYGEO_DIR/Cargo.toml" --release
33+
34+
WHEEL=$(ls "$RAYGEO_DIR"/target/wheels/raygeo-*.whl)
35+
echo "Wheel built: $WHEEL"
36+
37+
echo "Installing wheel into pixi environment..."
38+
pixi run uv pip install --no-cache --no-deps --force-reinstall "$WHEEL"
39+
40+
# uv pip install does not reliably replace the .so file in the site-packages
41+
# directory. Extract it manually from the wheel to ensure the new binary
42+
# is used.
43+
SITE_PACKAGES=$(pixi run python -c "import site; print(site.getsitepackages()[0])")
44+
unzip -o "$WHEEL" raygeo/raygeo.abi3.so -d "$SITE_PACKAGES/"

0 commit comments

Comments
 (0)