Skip to content

Add packaged Windows App SDK bootstrap for Python and Node.js - #225

Merged
leileizhang (lei9444) merged 5 commits into
mainfrom
lei9444-python-winui-bootstrap-helper
Oct 29, 2026
Merged

leileizhang (lei9444) merged 5 commits into
mainfrom
lei9444-python-winui-bootstrap-helper

Conversation

@lei9444

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

Copy link
Copy Markdown
Contributor

Summary

Package Windows App SDK Bootstrap configuration and DLLs with generated Python and JavaScript bindings. Applications can then use the existing initialization APIs without maintaining project-specific SDK paths, version constants, or Bootstrap environment variables.

Changes

  • Add --winappsdk-version and repeatable --winappsdk-bootstrap-path options accepting DLL files or directories. Directory discovery recursively matches Microsoft.WindowsAppRuntime.Bootstrap.dll only within the supplied trees. PE content identifies x64/ARM64; unsupported directory matches are reported and ignored, while unsupported explicit files are rejected. Identical payloads are deduplicated, while conflicting binaries or license files are rejected.
  • Include the configuration, Bootstrap DLLs, and redistribution notices in generated wheels and npm packages. Resource lookup is relative to the installed package rather than the project or working directory.
  • Support no-argument initialization through installed Python package metadata and normal JavaScript package imports. Existing explicit-version calls, environment overrides, and return types remain supported.
  • Preserve Bootstrap resources across incremental generation and leave existing output unchanged when validation fails.

Usage

Given WinMD input/reference lists and Bootstrap DLLs from the same Windows App SDK release:

dynwinrt-codegen generate --lang py `
  --winmd-list .\winmd-inputs.txt --ref-list .\winmd-references.txt `
  --output .\app_bindings --winappsdk-version 2.5 `
  --winappsdk-bootstrap-path .\sdk

Repeat --winappsdk-bootstrap-path to supply individual DLLs, additional directories, or both. Each supplied directory must contain a supported DLL. --winappsdk-version is the stable product MAJOR.MINOR, not a full NuGet servicing version.

Install the generated package with the matching DynWinRT runtime. Within the application's existing COM apartment, Python can initialize the SDK without importing the generated bindings first:

from dynwinrt import init_winappsdk

bootstrap = init_winappsdk()

For Node.js, generate with --lang js and import the generated package before initialization:

import { initWinappsdk } from '@microsoft/dynwinrt';
import '@winapp/bindings';

initWinappsdk();

Compatibility

The Windows App Runtime must still be installed. Bundling the Bootstrap DLL does not provide self-contained deployment, and configuration imports do not initialize COM or the Runtime. Applications retain control of initialization and UI lifetime.

JavaScript Bootstrap bundling requires --import-name to identify a scoped or unscoped npm package exposing /winappsdk (default @microsoft/dynwinrt). File paths and package subpaths are rejected before output changes, including subsequent passes without Bootstrap options. Generation without Bootstrap bundling retains existing file-import support.

This change does not add support for architectures other than x64 and ARM64. SDK binaries retain their original redistribution terms; no SDK binaries are committed to this repository.

Validation

Windows SDK corpus tests use a versioned, SHA-256-verified metadata fixture rather than the runner's installed SDK. Existing corpus counts and member assertions remain unchanged; this pin applies only to tests, not application SDK selection.

  • cargo test -p dynwinrt-codegen --lib --quiet: 664 passed; one existing ignored test.
  • cargo test -p dynwinrt-codegen --bin dynwinrt-codegen --test winappsdk_bundle_test --test python_generator_version_test --quiet: 81 CLI, 30 Bootstrap bundle, and 5 producer-version tests passed.
  • python -m pytest bindings\py\tests -q: passed; 14 existing optional WinUI skips.
  • python -m mypy.stubtest dynwinrt --allowlist bindings\py\stubtest_allowlist.txt --ignore-disjoint-bases: passed with mypy 1.20.2 and a rebuilt runtime wheel.

Package-generation and installation checks cover repeated and overlapping inputs, conflicts, incremental generation, Python wheels/editable installs, and packed npm installations from different working directories. Eighteen real-SDK directory/file/package checks passed for Python and JavaScript, including x64/ARM64 output, ARM64EC duplicates identified as x64, and x86 diagnostics. Node/npm checks also cover scoped and unscoped runtime packages, rejected file imports, retained bundles, and working unconfigured relative/absolute file imports. Regression tests also cover linked or unreadable inputs and atomic failure rollback. Native ARM64 execution and local ARM64 builds remain unverified; the local ARM64 MSVC toolchain is unavailable.

Generate package-local Bootstrap resources for Python and Node.js and support configuration-driven calls to the existing initializers.

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

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.64% 82.13% 86.27% regions
Python aggregate 70.74% n/a 37.66% branches
Python runtime 98.03% n/a 94.03% branches
Generated Python WinRT projections 68.82% n/a 30.41% branches
Generated Python WinRT implementations 72% n/a 46.3% branches
JavaScript aggregate 18.38% 24.85% 55.94% branches
JavaScript runtime 41.73% 41.53% 78.33% branches
Generated WinRT projections 17.27% 19.36% 52.51% branches
Generated WinRT implementations 45.99% 59.19% 60.97% branches
Generated Classic COM projections 11.38% 23.88% 53.1% branches

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

leileizhang (lei9444) and others added 2 commits October 28, 2026 18:24
Use the existing native-module import pattern for Bootstrap configuration. Restore one checksum-verified SDK corpus in Build and coverage while preserving exact member and dispatcher assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Accept short-name and long-name spellings of the same verified metadata file in CI without weakening the content check.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
leileizhang (lei9444) added a commit that referenced this pull request Oct 28, 2026
Restore and verify one SDK corpus in Build and coverage instead of reading the runner's rolling installation. Reuse the CI-only pinning fix from PR #225 and preserve exact nullability and dispatcher assertions without changing production generation.

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

Copilot-Session: ba086f9c-a9d8-4e7e-abb3-d0fea864064c
leileizhang (lei9444) and others added 2 commits October 28, 2026 22:33
Use --winappsdk-bootstrap-path for repeatable file or directory inputs. Discover matching DLLs only within supplied trees, identify architecture from PE data, and preserve strict explicit-file validation and atomic bundle publication.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Require an npm package-root import for JavaScript Bootstrap registration and peer dependencies, including retained bundles in later generation passes. Preserve file-based runtime imports when Bootstrap bundling is disabled and report unsupported combinations before changing output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
leileizhang (lei9444) added a commit that referenced this pull request Oct 29, 2026
* Accept string keys in Python ResourceDictionary projections

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c000b813-441b-407a-bac9-7d03e70279c0

* Fix string enum keys in Python ResourceDictionary

Normalize ResourceDictionary string subclasses to their underlying str before explicit String boxing. Cover enum keys in generated stubs, inline consumers, native Mapping operations and the WinUI runner without changing generic Object boxing.

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

Copilot-Session: ba086f9c-a9d8-4e7e-abb3-d0fea864064c

* Pin Windows SDK metadata used by CI corpus tests

Restore and verify one SDK corpus in Build and coverage instead of reading the runner's rolling installation. Reuse the CI-only pinning fix from PR #225 and preserve exact nullability and dispatcher assertions without changing production generation.

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

Copilot-Session: ba086f9c-a9d8-4e7e-abb3-d0fea864064c

* Preserve inherited ResourceDictionary key contracts and default typing

Retain resolved WinMD ancestor identities and apply the checked ResourceDictionary key contract to derived projections. Emit Mapping default TypeVars at module scope for Pyright inference and runtime annotation resolution. Add independent-default-interface and multilevel inheritance controls, pinned-Pyright inline/stub checks, and unchanged generic Object-map coverage.

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

Copilot-Session: ba086f9c-a9d8-4e7e-abb3-d0fea864064c

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c000b813-441b-407a-bac9-7d03e70279c0
Copilot-Session: ba086f9c-a9d8-4e7e-abb3-d0fea864064c
@lei9444
leileizhang (lei9444) merged commit 2159d6e into main Oct 29, 2026
33 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-python-winui-bootstrap-helper branch October 29, 2026 03:17
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.

2 participants