Skip to content

Commit 429b8c1

Browse files
yggdrasil-engine: Add version 2.0.0 (#2814)
* yggdrasil-engine: Add version 2.0.0 Signed-off-by: riseproject-dev[bot] <330740410+riseproject-dev[bot]@users.noreply.github.com> * yggdrasil-engine: carry forward riscv64 patches to 2.0.0 Nightly version bump omitted the patches/yggdrasil-engine/<version> directory for 2.0.0, so the build's unconditional `git apply .../*.patch` step failed with "No such file or directory" before any build/test ran. Copied forward the same patch set from 1.3.1 (unchanged since then). * yggdrasil-engine: update smoke test for 2.0.0 is_enabled API yggdrasil-engine 2.0.0 changed UnleashEngine.is_enabled from returning Optional[bool] (None for a toggle missing from the engine state) to returning a FeatureToggle. An unknown toggle without a fallback now yields is_enabled=False, is_found=False, and FeatureToggle.__bool__ raises TypeError, so both `is True` and `is None` checks failed. Check .is_enabled/.is_found on 2.x (mirroring upstream's test_is_enabled_reports_not_found_when_toggle_missing_without_fallback) and keep the old True/None checks for 1.x rebuilds. --------- Signed-off-by: riseproject-dev[bot] <330740410+riseproject-dev[bot]@users.noreply.github.com> Co-authored-by: riseproject-dev[bot] <330740410+riseproject-dev[bot]@users.noreply.github.com> Co-authored-by: Ludovic Henry <git@ludovic.dev>
1 parent 67f196b commit 429b8c1

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

‎.github/workflows/build-yggdrasil-engine.yml‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,27 @@ jobs:
166166
- name: Install wheel
167167
run: uv pip install --reinstall --no-index --find-links . yggdrasil-engine==${{ env.YGGDRASIL_ENGINE_VERSION }}
168168

169+
# 2.0.0 changed is_enabled from returning Optional[bool] (None for an
170+
# unknown toggle) to returning a FeatureToggle, whose unknown-toggle
171+
# answer is is_enabled=False, is_found=False and whose __bool__ raises
172+
# TypeError (upstream python-engine/tests/test_engine.py,
173+
# test_is_enabled_reports_not_found_when_toggle_missing_without_fallback).
169174
- name: Test wheel
170175
run: |
171176
python -c "
177+
from importlib.metadata import version
172178
from yggdrasil_engine.engine import UnleashEngine
173179
174180
engine = UnleashEngine()
175181
engine.take_state('{\"version\": 2, \"features\": [{\"name\": \"my-toggle\", \"enabled\": true, \"strategies\": [{\"name\": \"default\"}]}]}')
176-
assert engine.is_enabled('my-toggle', {}) is True
177-
assert engine.is_enabled('missing-toggle', {}) is None
182+
hit = engine.is_enabled('my-toggle', {})
183+
miss = engine.is_enabled('missing-toggle', {})
184+
if int(version('yggdrasil-engine').split('.')[0]) >= 2:
185+
assert (hit.name, hit.is_enabled, hit.is_found) == ('my-toggle', True, True), hit
186+
assert (miss.name, miss.is_enabled, miss.is_found) == ('missing-toggle', False, False), miss
187+
else:
188+
assert hit is True, hit
189+
assert miss is None, miss
178190
print('Smoke test passed')
179191
"
180192

‎docs/packages/yggdrasil-engine.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ versions:
99
- filename: yggdrasil_engine-1.3.1-cp312-abi3-manylinux_2_39_riscv64.whl
1010
sha256: 3dcbd624fa5ebeb43d6c1957397f77652b9fd24a0118e009c7119edf185f4f21
1111
requires-python: '>=3.8,<4.0'
12+
- version: 2.0.0
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 79a1d5318f08a15066d691f90d263496edd4b227 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Sun, 13 Sep 2026 01:34:34 +0200
4+
Subject: [PATCH] yggdrasilffi: add riscv64 syscall numbers for gettid/statx
5+
compat shim
6+
7+
compat_glibc.rs hand-rolls gettid(2)/statx(2) via raw syscall(2) to
8+
avoid depending on the libc crate's own bindings, which would require
9+
a newer glibc than the zigbuild-targeted GLIBC_2.25 floor. It defines
10+
SYS_GETTID/SYS_STATX for x86_64 and aarch64 only; mod compat_glibc is
11+
included unconditionally (no target_arch gate), so on any other arch
12+
- riscv64 included - the crate fails to compile with two
13+
cannot-find-value errors for the two undefined consts.
14+
15+
riscv64 and aarch64 both use the Linux kernel's generic syscall table
16+
(include/uapi/asm-generic/unistd.h: __NR_gettid 178, __NR_statx 291,
17+
confirmed also in the libc crate's own riscv64 module), unlike x86_64,
18+
which has its own legacy numbering. Add the same two constants under
19+
target_arch = "riscv64".
20+
21+
Upstream-Status: To upstream [not filed upstream from this porting session, which does not open issues/PRs on repos other than riseproject-dev/python-wheels; genuinely worth upstreaming, it only adds an arch branch matching aarch64's already-supported case]
22+
23+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
24+
---
25+
yggdrasilffi/src/compat_glibc.rs | 6 ++++++
26+
1 file changed, 6 insertions(+)
27+
28+
diff --git a/yggdrasilffi/src/compat_glibc.rs b/yggdrasilffi/src/compat_glibc.rs
29+
index c13446d..1a115ac 100644
30+
--- a/yggdrasilffi/src/compat_glibc.rs
31+
+++ b/yggdrasilffi/src/compat_glibc.rs
32+
@@ -32,6 +32,12 @@ const SYS_GETTID: c_long = 178;
33+
#[cfg(target_arch = "aarch64")]
34+
const SYS_STATX: c_long = 291;
35+
36+
+// riscv64 syscall numbers (riscv64 shares aarch64's asm-generic/unistd.h table)
37+
+#[cfg(target_arch = "riscv64")]
38+
+const SYS_GETTID: c_long = 178;
39+
+#[cfg(target_arch = "riscv64")]
40+
+const SYS_STATX: c_long = 291;
41+
+
42+
#[no_mangle]
43+
pub unsafe extern "C" fn gettid() -> pid_t {
44+
syscall(SYS_GETTID) as pid_t
45+
--
46+
2.50.1 (Apple Git-155)
47+

0 commit comments

Comments
 (0)