Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180237
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (2 Unrelated Failures)As of commit d22cf34 with merge base bef98a5 ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Generate LICENSES_BUNDLED.txt at build time by calling third_party/build_bundled.py, and install it as LICENSE in the wheel. The setuptools concat_license_files context manager remains for setuptools builds. Co-Generated with [Claude Code](https://claude.com/claude-code) ghstack-source-id: 5762514 Pull-Request: pytorch#180237
Generate LICENSES_BUNDLED.txt at build time by calling third_party/build_bundled.py, and install it as LICENSE in the wheel. The setuptools concat_license_files context manager remains for setuptools builds. Co-Generated with [Claude Code](https://claude.com/claude-code) ghstack-source-id: 5762514 Pull-Request: pytorch#180237
Generate LICENSES_BUNDLED.txt at build time by calling third_party/build_bundled.py, and install it as LICENSE in the wheel. The setuptools concat_license_files context manager remains for setuptools builds. Co-Generated with [Claude Code](https://claude.com/claude-code) ghstack-source-id: 5762514 Pull-Request: pytorch#180237
The PEP 639 migration in the following commit ("Drop setuptools
concat_license_files; adopt PEP 639 license-files") requires
setuptools>=77, which in turn requires packaging>=24.2 to validate
the PEP 639 license expressions in pyproject.toml. The CI docker
image still pinned packaging==24.0.
The version is matched to the floor declared alongside the setuptools
bump in pyproject.toml and requirements-build.txt.
Landing this one-line bump on its own so the docker image refresh
propagates independently of the license PR (pytorchgh-180237), which had
been flaking on docker image rebuild races.
Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: pytorch#183700
Approved by: https://github.com/atalman
…77644) Adds `cmake/PostBuildSteps.cmake` with two post-build steps previously handled by `setup.py`'s `build_ext.run()`: - **`TORCH_STABLE_ONLY` header wrapping** — runs `tools/wrap_headers.py` at install time to add guards to installed headers. Headers wrapped this way error when included with `TORCH_STABLE_ONLY` or `TORCH_TARGET_VERSION` defined. - **`compile_commands.json` merging** — runs `tools/merge_compile_commands.py` as a build target to combine compile commands from cmake build subdirectories into a single file at the project root. Both `wrap_headers.py` and `merge_compile_commands.py` are extracted from inline code in `setup.py` into standalone scripts under `tools/`. The corresponding code is removed from `setup.py`'s `build_ext` class (97 lines removed). This creates the `PostBuildSteps.cmake` module that subsequent PRs (pytorch#180237, pytorch#180238, pytorch#180239) extend with license bundling, Windows DLL bundling, and macOS OpenMP embedding. Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#177644 Approved by: https://github.com/atalman
…torch#180237) ## Context This PR started out as an attempt to port the license file handling, including the concatenation and overwriting of the original LICENSE to a cmake controlled version. However, that proved tricky and brittle, as particularly the overwrite of the LICENSE file introduces race conditions and failure modes for, for example, subsequent builds in the same directory. Instead, [PEP 639](https://peps.python.org/pep-0639/) gives us a clean alternative by embedding all the license files in the wheel. That is why this PR ended up also covering some aspects of pytorch#158104, though hopefully with a smaller footprint; because of the discussion over there, I also triggered a manual check of [`inductor-perf-test-nightly-macos.yml`](https://github.com/pytorch/pytorch/actions/runs/25632518115), which came back green. ## Summary Replace the legacy "concatenate every third-party `LICENSE` into the top-level `LICENSE` during `bdist_wheel`" mechanism with the standard [PEP 639](https://peps.python.org/pep-0639/) `license-files` field. Setuptools 77+ implements PEP 639 with directory-preserving placement at `*.dist-info/licenses/<path>`, and scikit-build-core's `tool.scikit-build.wheel.license-files` was already configured the same way during the migration. ## What changes - `setup.py`: remove the `concat_license_files` context manager and its `bdist_wheel` / `sdist` command-class overrides. - `pyproject.toml`: declare `[project].license-files` (mirrors the `tool.scikit-build.wheel.license-files` glob already present), and migrate `license = { text = "BSD-3-Clause" }` to the PEP 639 string form `license = "BSD-3-Clause"` (resolves the existing TODO; the table form is deprecated in setuptools 77+). - `requirements-build.txt` and the `dev` dependency group: bump `setuptools` to `>=77.0.0`, the first release implementing PEP 639. - `third_party/build_bundled.py` and `third_party/LICENSES_BUNDLED.txt`: deleted. The script existed to feed `concat_license_files`; with PEP 639 each third-party license ships individually at its own path, so the concatenation step (and the checked-in artifact it produced) are no longer needed. - `test/test_license.py`: drop the source-tree check that validated `LICENSES_BUNDLED.txt` against `build_bundled.py`. Replace the dist-info check with one that verifies at least one third-party license is shipped under `<dist-info>/licenses/third_party/`. ## Behavior change for downstream consumers Compliance is preserved end-to-end — every third-party license still ships in the wheel. The change is layout, not content: | | Before | After | | --- | --- | --- | | Top-level | `*.dist-info/licenses/LICENSE` (~342 KB, concatenated) | `*.dist-info/licenses/LICENSE` (bare BSD-3-Clause) | | Per-library | (none) | `*.dist-info/licenses/third_party/<lib>/LICENSE` | Tools that scanned a single `LICENSE` file will need to walk the `dist-info` `licenses/` tree instead. ## Replaces This subsumes pytorch#182122, which updated `test_license.py` against `main` to support both the legacy and PEP 639 layouts. With the migration landing in this PR, the legacy branch becomes unreachable, so the test is rewritten directly here. ## Test plan - [x] `pytest test/test_license.py` (skips outside an installed wheel; runs and verifies third-party licenses on a built wheel) - [x] Inspect a fresh wheel: `*.dist-info/licenses/LICENSE` contains only the BSD-3-Clause text; `*.dist-info/licenses/third_party/<lib>/LICENSE` exists for representative submodules Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#180237 Approved by: https://github.com/rgommers, https://github.com/atalman, https://github.com/malfet
Install runtime DLLs (OpenMP, libuv, CUDA) into the wheel on Windows via CMake install steps, supporting the scikit-build-core migration. This replaces the equivalent CI copy.bat / copy_cpu.bat scripts that copied DLLs into the source tree before setuptools ran. The setup.py logic that copies torch/lib/_C.lib stays in place here; once _C is built by CMake (later in the stack) the install for that file moves to the same CMakeLists.txt that defines the target. Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#180238 Approved by: https://github.com/atalman ghstack dependencies: pytorch#180237
…80238)" This reverts commit 1e2a0b0. Reverted pytorch#180238 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#180237 (comment)))
…iles (pytorch#180237)" This reverts commit 70bae40. Reverted pytorch#180237 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#180237 (comment)))
…torch#180237) ## Context This PR started out as an attempt to port the license file handling, including the concatenation and overwriting of the original LICENSE to a cmake controlled version. However, that proved tricky and brittle, as particularly the overwrite of the LICENSE file introduces race conditions and failure modes for, for example, subsequent builds in the same directory. Instead, [PEP 639](https://peps.python.org/pep-0639/) gives us a clean alternative by embedding all the license files in the wheel. That is why this PR ended up also covering some aspects of pytorch#158104, though hopefully with a smaller footprint; because of the discussion over there, I also triggered a manual check of [`inductor-perf-test-nightly-macos.yml`](https://github.com/pytorch/pytorch/actions/runs/25632518115), which came back green. ## Summary Replace the legacy "concatenate every third-party `LICENSE` into the top-level `LICENSE` during `bdist_wheel`" mechanism with the standard [PEP 639](https://peps.python.org/pep-0639/) `license-files` field. Setuptools 77+ implements PEP 639 with directory-preserving placement at `*.dist-info/licenses/<path>`, and scikit-build-core's `tool.scikit-build.wheel.license-files` was already configured the same way during the migration. ## What changes - `setup.py`: remove the `concat_license_files` context manager and its `bdist_wheel` / `sdist` command-class overrides. - `pyproject.toml`: declare `[project].license-files` (mirrors the `tool.scikit-build.wheel.license-files` glob already present), and migrate `license = { text = "BSD-3-Clause" }` to the PEP 639 string form `license = "BSD-3-Clause"` (resolves the existing TODO; the table form is deprecated in setuptools 77+). - `requirements-build.txt` and the `dev` dependency group: bump `setuptools` to `>=77.0.0`, the first release implementing PEP 639. - `third_party/build_bundled.py` and `third_party/LICENSES_BUNDLED.txt`: deleted. The script existed to feed `concat_license_files`; with PEP 639 each third-party license ships individually at its own path, so the concatenation step (and the checked-in artifact it produced) are no longer needed. - `test/test_license.py`: drop the source-tree check that validated `LICENSES_BUNDLED.txt` against `build_bundled.py`. Replace the dist-info check with one that verifies at least one third-party license is shipped under `<dist-info>/licenses/third_party/`. ## Behavior change for downstream consumers Compliance is preserved end-to-end — every third-party license still ships in the wheel. The change is layout, not content: | | Before | After | | --- | --- | --- | | Top-level | `*.dist-info/licenses/LICENSE` (~342 KB, concatenated) | `*.dist-info/licenses/LICENSE` (bare BSD-3-Clause) | | Per-library | (none) | `*.dist-info/licenses/third_party/<lib>/LICENSE` | Tools that scanned a single `LICENSE` file will need to walk the `dist-info` `licenses/` tree instead. ## Replaces This subsumes pytorch#182122, which updated `test_license.py` against `main` to support both the legacy and PEP 639 layouts. With the migration landing in this PR, the legacy branch becomes unreachable, so the test is rewritten directly here. ## Test plan - [x] `pytest test/test_license.py` (skips outside an installed wheel; runs and verifies third-party licenses on a built wheel) - [x] Inspect a fresh wheel: `*.dist-info/licenses/LICENSE` contains only the BSD-3-Clause text; `*.dist-info/licenses/third_party/<lib>/LICENSE` exists for representative submodules Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#180237 Approved by: https://github.com/rgommers, https://github.com/atalman, https://github.com/malfet
Install runtime DLLs (OpenMP, libuv, CUDA) into the wheel on Windows via CMake install steps, supporting the scikit-build-core migration. This replaces the equivalent CI copy.bat / copy_cpu.bat scripts that copied DLLs into the source tree before setuptools ran. The setup.py logic that copies torch/lib/_C.lib stays in place here; once _C is built by CMake (later in the stack) the install for that file moves to the same CMakeLists.txt that defines the target. Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#180238 Approved by: https://github.com/atalman ghstack dependencies: pytorch#180237
…80238)" This reverts commit a938856. Reverted pytorch#180238 on behalf of https://github.com/huydhn due to Sorry for reverting your change but another dynamo test failure shows up ([comment](pytorch#180237 (comment)))
…iles (pytorch#180237)" This reverts commit abd8c6c. Reverted pytorch#180237 on behalf of https://github.com/huydhn due to Sorry for reverting your change but another dynamo test failure shows up ([comment](pytorch#180237 (comment)))
The PEP 639 migration in the following commit ("Drop setuptools
concat_license_files; adopt PEP 639 license-files") requires
setuptools>=77, which in turn requires packaging>=24.2 to validate
the PEP 639 license expressions in pyproject.toml. The CI docker
image still pinned packaging==24.0.
The version is matched to the floor declared alongside the setuptools
bump in pyproject.toml and requirements-build.txt.
Landing this one-line bump on its own so the docker image refresh
propagates independently of the license PR (gh-180237), which had
been flaking on docker image rebuild races.
Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: #183700
Approved by: https://github.com/atalman
|
@pytorchbot drci |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: windows-arm64-binary-wheel / wheel-py3_12-cpu-build Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Install runtime DLLs (OpenMP, libuv, CUDA) into the wheel on Windows via CMake install steps, supporting the scikit-build-core migration. This replaces the equivalent CI copy.bat / copy_cpu.bat scripts that copied DLLs into the source tree before setuptools ran. The setup.py logic that copies torch/lib/_C.lib stays in place here; once _C is built by CMake (later in the stack) the install for that file moves to the same CMakeLists.txt that defines the target. Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: #180238 Approved by: https://github.com/atalman ghstack dependencies: #183700, #180237
…77644) Adds `cmake/PostBuildSteps.cmake` with two post-build steps previously handled by `setup.py`'s `build_ext.run()`: - **`TORCH_STABLE_ONLY` header wrapping** — runs `tools/wrap_headers.py` at install time to add guards to installed headers. Headers wrapped this way error when included with `TORCH_STABLE_ONLY` or `TORCH_TARGET_VERSION` defined. - **`compile_commands.json` merging** — runs `tools/merge_compile_commands.py` as a build target to combine compile commands from cmake build subdirectories into a single file at the project root. Both `wrap_headers.py` and `merge_compile_commands.py` are extracted from inline code in `setup.py` into standalone scripts under `tools/`. The corresponding code is removed from `setup.py`'s `build_ext` class (97 lines removed). This creates the `PostBuildSteps.cmake` module that subsequent PRs (pytorch#180237, pytorch#180238, pytorch#180239) extend with license bundling, Windows DLL bundling, and macOS OpenMP embedding. Co-Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#177644 Approved by: https://github.com/atalman
Stack from ghstack (oldest at bottom):
Context
This PR started out as an attempt to port the license file handling, including the concatenation and overwriting of the original LICENSE to a cmake controlled version. However, that proved tricky and brittle, as particularly the overwrite of the LICENSE file introduces race conditions and failure modes for, for example, subsequent builds in the same directory. Instead, PEP 639 gives us a clean alternative by embedding all the license files in the wheel.
That is why this PR ended up also covering some aspects of #158104, though hopefully with a smaller footprint; because of the discussion over there, I also triggered a manual check of
inductor-perf-test-nightly-macos.yml, which came back green.Summary
Replace the legacy "concatenate every third-party
LICENSEinto the top-levelLICENSEduringbdist_wheel" mechanism with the standard PEP 639license-filesfield. Setuptools 77+ implements PEP 639 with directory-preserving placement at*.dist-info/licenses/<path>, and scikit-build-core'stool.scikit-build.wheel.license-fileswas already configured the same way during the migration.What changes
setup.py: remove theconcat_license_filescontext manager and itsbdist_wheel/sdistcommand-class overrides.pyproject.toml: declare[project].license-files(mirrors thetool.scikit-build.wheel.license-filesglob already present), and migratelicense = { text = "BSD-3-Clause" }to the PEP 639 string formlicense = "BSD-3-Clause"(resolves the existing TODO; the table form is deprecated in setuptools 77+).requirements-build.txtand thedevdependency group: bumpsetuptoolsto>=77.0.0, the first release implementing PEP 639.third_party/build_bundled.pyandthird_party/LICENSES_BUNDLED.txt: deleted. The script existed to feedconcat_license_files; with PEP 639 each third-party license ships individually at its own path, so the concatenation step (and the checked-in artifact it produced) are no longer needed.test/test_license.py: drop the source-tree check that validatedLICENSES_BUNDLED.txtagainstbuild_bundled.py. Replace the dist-info check with one that verifies at least one third-party license is shipped under<dist-info>/licenses/third_party/.Behavior change for downstream consumers
Compliance is preserved end-to-end — every third-party license still ships in the wheel. The change is layout, not content:
*.dist-info/licenses/LICENSE(~342 KB, concatenated)*.dist-info/licenses/LICENSE(bare BSD-3-Clause)*.dist-info/licenses/third_party/<lib>/LICENSETools that scanned a single
LICENSEfile will need to walk thedist-infolicenses/tree instead.Replaces
This subsumes #182122, which updated
test_license.pyagainstmainto support both the legacy and PEP 639 layouts. With the migration landing in this PR, the legacy branch becomes unreachable, so the test is rewritten directly here.Test plan
pytest test/test_license.py(skips outside an installed wheel; runs and verifies third-party licenses on a built wheel)*.dist-info/licenses/LICENSEcontains only the BSD-3-Clause text;*.dist-info/licenses/third_party/<lib>/LICENSEexists for representative submodulesCo-Generated with Claude Code
cc @XuehaiPan