Skip to content

Commit c534ecd

Browse files
committed
fix(cuda_core): force UTF-8 mode for stubgen-pyx pre-commit hook
Windows CI (and local Windows developers) were regenerating .pyi files with corrupted non-ASCII characters (e.g. Kepler(TM) -> Kepler mojibake). stubgen-pyx's `include`-directive expansion reads .pxi files via `Path.read_text()` with no explicit encoding, which falls back to the platform's default (cp1252 on Windows) instead of UTF-8. `_device.pyx` pulls in several .pxi files with UTF-8 docstring content ("Kepler(TM)", "(in {mu}s)"), so this only surfaces there. Invoke stubgen-pyx via `python -X utf8 -m stubgen_pyx` so Python's UTF-8 mode is forced regardless of platform locale, matching what the old toolshed/run_stubgen_pyx.py wrapper did via PYTHONUTF8=1 before it was removed. Putting this in .pre-commit-config.yaml (rather than only in CI) means local Windows developers get the same fix. This also revert the temporary --show-diff-on-failure diagnostic flag added to track down the mismatch. Root cause filed upstream: jon-edward/stubgen-pyx#41 (encoding fix was incomplete - it covered top-level .pyx/.pxd reads but missed the include-expansion path in file_parsing.py).
1 parent 7d19656 commit c534ecd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ jobs:
531531
shell: bash
532532
run: |
533533
set -euxo pipefail
534-
SKIP=lychee pre-commit run --all-files --show-diff-on-failure
534+
SKIP=lychee pre-commit run --all-files
535535
536536
checks:
537537
name: Check job status

‎.pre-commit-config.yaml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ repos:
8383

8484
- id: stubgen-pyx-cuda-core
8585
name: Generate .pyi stubs for cuda_core
86-
entry: stubgen-pyx cuda_core/cuda --continue-on-error --include-private
86+
# -X utf8 forces Python's UTF-8 mode so file reads/writes don't fall
87+
# back to the platform's default encoding (e.g. cp1252 on Windows),
88+
# which otherwise corrupts non-ASCII characters (e.g. "™", "μ") in
89+
# `include`d .pxi files. See jon-edward/stubgen-pyx#41.
90+
entry: python -X utf8 -m stubgen_pyx cuda_core/cuda --continue-on-error --include-private
8791
language: python
8892
files: ^cuda_core/cuda/.*\.(pyx|pxd)$
8993
pass_filenames: false

0 commit comments

Comments
 (0)