Repository navigation
Conversation
PEP 639 standardizes how license files are included in Python packages, placing them in a licenses/ subdirectory of dist-info. Both setuptools 77+ and scikit-build-core follow this layout. Update the test to check both the legacy combined LICENSE file and the PEP 639 directory structure. Co-Generated with [Claude Code](https://claude.com/claude-code)
|
@claude please review this PR |
|
Claude finished @atalman's task in 1m 28s —— View job PR Review: Update test_license.py for PEP 639 license layout
Summary: This PR updates Overall: Looks good. The logic is clear and covers the three relevant scenarios correctly:
Minor observations
No bugs or correctness issues found. The change is well-structured and the fallback logic is sound. Verdict: Approve ✓ |
|
Closing in favor of folding this into #180237 — that PR is what makes the legacy combined-LICENSE codepath disappear, so it's the right place to update the test. The fixup there also drops |
…80237) ## 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 #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 #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: #180237 Approved by: https://github.com/rgommers, https://github.com/atalman, https://github.com/malfet
…80237) ## 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 #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 #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: #180237 Approved by: https://github.com/rgommers, https://github.com/atalman, https://github.com/malfet
…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
…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
…80237) ## 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 #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 #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: #180237 Approved by: https://github.com/rgommers, https://github.com/atalman, https://github.com/malfet ghstack dependencies: #183700
…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
…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
…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 ghstack dependencies: pytorch#183700
…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
…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
…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 ghstack dependencies: pytorch#183700
PEP 639 standardizes how license files are included in Python packages, placing them in a licenses/ subdirectory of dist-info. Both setuptools 77+ and scikit-build-core follow this layout. Update the test to check both the legacy combined LICENSE file and the PEP 639 directory structure.
Co-Generated with Claude Code
Replaces #180244.