Developer Tools

trunk/059c270b1c5f45981c1a04246869b76b6fc36b7e: Add cmake/PackageData.cmake for scikit-build-core migration (#177643)

New cmake rules replace package_data globs, enabling scikit-build-core migration.

Deep Dive

PyTorch (99.6k stars on GitHub) added `cmake/PackageData.cmake`, which installs non-Python data files (type stubs, benchmark utilities, inductor codegen files, export serde data, etc.) into the wheel via cmake `install()` rules. This replaces the `package_data` globs in `setup.py` as the mechanism for including these files under scikit-build-core. Covered file categories include type stubs, benchmark C++ sources and valgrind wrapper headers, model dump HTML/JS/MJS files, inductor codegen headers/linker scripts/jinja templates, export serde YAML and Thrift schemas, AOTInductor runtime headers, generated test files (`annotated_fn_args.py`), and dynamo graph break registry. For setuptools, install destinations resolve to `<root>/torch/` where source files already live, making them harmless self-copies. `setup.py`'s `package_data` declarations remain necessary for setuptools to include these files.

Key Points
  • Adds cmake/PackageData.cmake to replace package_data globs in setup.py with cmake install() rules
  • Covers type stubs, benchmark files, inductor codegen headers, export schemas, and AOTInductor runtime headers
  • Part of migration to scikit-build-core for faster, more maintainable wheel builds

Why It Matters

Modernizing PyTorch's build system accelerates packaging and reduces technical debt for millions of ML practitioners.