Skip to content

Warn about generated Python Windows output path lengths - #210

Open
leileizhang (lei9444) wants to merge 3 commits into
mainfrom
lei9444-python-path-diagnostics
Open

leileizhang (lei9444) wants to merge 3 commits into
mainfrom
lei9444-python-path-diagnostics

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Rust can emit generated Python files that ordinary Windows Python imports, mypy, or pip cannot open. The existing 120-character module-component budget cannot constrain an arbitrary output root.

Fix

Emit one actionable stderr warning before transactional publication, using the actual final generated .py/.pyi inventory, including namespace facades. Report the longest representative path, its UTF-16 length, and the shorter-output budget at the legacy 260-unit boundary. Resolve the caller's logical absolute path without counting extended prefixes, staging directories, or a junction's longer target. Dry runs aggregate all selected namespaces into one warning without writing; --no-pyi excludes stubs.

Document preferred short output/checkouts and validated same-path junction/subst recipes, with primary Windows/Python references. Generation still succeeds; generated names, imports, layout, bytes, manifests, runtime ABI, versions, and machine configuration are unchanged.

A separate additive CI-only prerequisite carries the exact authorized patch from 49c7e6e2e7042b527f1fee9d6655a8df8f537099: accept trailing commas in the existing test-hook stub! macro and format two calls for hosted Rust 1.99. Native signatures and behavior are unchanged; no functional feature prerequisite is imported.

Verification

cargo fmt --all -- --check and the original 57 focused Rust checks passed. Follow-up passed 4 CLI regressions, 7 path/classifier tests and 6 snapshots, including eight types across two namespaces yielding exactly one dry-run warning and no filesystem writes. cargo check -p jswinrt_rs --features test-hooks --lib passed for both ARM64 and x64. One additional JS-dependent naming check was unavailable without the built bindings\js\dist\winrt.js runtime.

Native Windows ARM64 / CPython 3.13.15 / LongPathsEnabled=0, using an isolated runtime wheel built from this main-based checkout:

Consumer path Longest .py / .pyi Result
Deep output 261 / 262 Codegen exits 0 with one warning; import, strict mypy, package build fail
Short output 159 / 160 No warning; 147 modules import, strict mypy and package installation pass
Same-byte junction 161 / 162 No warning; import, strict mypy and installation pass
Same-byte subst 145 / 146 No warning; import, strict mypy and installation pass

All 303 generated files are byte-identical to unchanged main and across these paths. The documented relative-output junction recipe also passed generation/import/mypy/install.

Limitations

Diagnostic only, not an automatic long-path guarantee. Pip build staging and deep venv/install destinations cannot all be predicted from codegen output. A short-built identical wheel still fails in a deep venv. The existing test_generated_python_long_paths.ps1 package build also fails identically on unchanged main in this long-path-disabled environment; this PR does not claim to fix it. No registry/TLS changes, module-layout redesign, or functional unmerged-branch dependencies.

leileizhang (lei9444) and others added 3 commits October 1, 2026 22:32
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Accept optional trailing commas and format the two existing macro calls required by hosted Rust 1.99. Generated native signatures and behavior are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Exercise eight generated types in two namespaces with one warning and no output writes. Document the existing global dry-run aggregation without changing generation behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.91% 82.48% 86.64% regions
Python aggregate 72.34% n/a 39.42% branches
Python runtime 98.17% n/a 94.57% branches
Generated Python WinRT projections 71.07% n/a 33.5% branches
Generated Python WinRT implementations 71.97% n/a 46.3% branches
JavaScript aggregate 21.91% 25.18% 57.61% branches
JavaScript runtime 44.27% 45.76% 78.99% branches
Generated WinRT projections 22.8% 18.7% 54.84% branches
Generated WinRT implementations 45.99% 59.19% 60.97% branches
Generated Classic COM projections 11.88% 23.97% 53.4% branches

View workflow run and download full HTML/LCOV/XML reports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant