Skip to content

Bump packaging in docker image to min version - #183700

Closed
zklaus wants to merge 1 commit into
gh/zklaus/58/basefrom
gh/zklaus/58/head
Closed

zklaus wants to merge 1 commit into
gh/zklaus/58/basefrom
gh/zklaus/58/head

Conversation

@zklaus

@zklaus zklaus commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

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

[ghstack-poisoned]
@zklaus
zklaus requested a review from a team as a code owner May 14, 2026 10:43
@pytorch-bot pytorch-bot Bot added no-runner-experiments Bypass Meta/LF runner determinator topic: not user facing topic category labels May 14, 2026
@pytorch-bot

pytorch-bot Bot commented May 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/183700

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 2 Unrelated Failures, 2 Unclassified Failures

As of commit 352078b with merge base bef98a5 (image):

NEW FAILURE - The following job has failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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.

@atalman atalman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zklaus

zklaus commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

I did my best to locate the origin of the dynamo error and filed #183712.

@zklaus

zklaus commented May 14, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -f "Dynamo error unrelated"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorch-auto-revert

Copy link
Copy Markdown

@pytorchbot revert -m "Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable" -c autorevert

This PR is attributed to have caused regression in:

Please investigate and fix the issues.
@claude Can you please read this revert comment, follow the links and read the errors, to then give a brief diagnostics on the cause of the error? If you judge the error to be legitimate reason for a revert, please provide brief guidance on how the author could fix it.

@huydhn

huydhn commented May 14, 2026

Copy link
Copy Markdown
Contributor

@claude Look into the failure coming from the PR test/dynamo/test_package.py::TestPackage::test_automatic_dynamo_graph_breaks_device_cpu GH job link HUD commit link and see if it's related to the change

@claude

claude Bot commented May 14, 2026 •

Copy link
Copy Markdown

Claude finished @huydhn's task in 6m 54s —— View job


Investigation: test_automatic_dynamo_graph_breaks_device_cpu failure

  • Download and analyze the CI job log
  • Read the failing test (test/dynamo/test_package.py)
  • Read the PR change (.ci/docker/requirements-ci.txt)
  • Determine if the failure is related to the packaging version bump
  • Provide final assessment

Finding

The failure is NOT related to this PR's change.

Evidence

  1. The PR change: A one-line bump in .ci/docker/requirements-ci.txt from packaging==24.0 to packaging==24.2. The packaging library is a Python packaging/version-parsing utility (for PEP 440 versions, PEP 508 requirements, etc.).

  2. The failing test: test/dynamo/test_package.py::TestPackage::test_automatic_dynamo_graph_breaks_device_cpu tests Dynamo's caching_precompile feature — serializing compiled graph artifacts to disk and reloading them. The test's "package" refers to Dynamo's CompilePackage/DynamoCache, not the packaging PyPI library. The test file does not import or use the packaging library at all.

  3. No code path connects them: grep -r "import packaging" torch/_dynamo/ returns zero results. The packaging library is used only by build/install tooling (pip, setuptools), not by Dynamo runtime or test infrastructure.

  4. The error: NameError: name '__compiled_fn_31_...' is not defined — this is a Dynamo code object serialization/deserialization failure when reloading cached compiled functions. It indicates a compiled function reference failed to resolve after the save-and-reload cycle. This is purely a Dynamo internals issue, unrelated to Python packaging metadata parsing.

  5. Python 3.14 specificity: The failure only occurs on linux-jammy-py3.14-clang18. Python 3.14 introduced significant changes to code objects and frames (PEP 749, etc.) that can affect Dynamo's bytecode manipulation. The test passes on all other Python versions.

  6. Pre-existing on trunk: As @zklaus pointed out, HUD shows this failure appearing 40+ times on main over the last two days across multiple branches. This is tracked in [caching_precompile] test_automatic_dynamo_graph_breaks_device_cpu regression starting 2026-05-13 on py3.14 #183712.

  7. Why the auto-revert triggered: The linux-jammy-py3.14-clang18 job configuration is relatively new and didn't run on the merge base commit, so the auto-revert bot had no baseline to compare against and incorrectly attributed the failure to this PR.

Conclusion

The packaging version bump (24.0 → 24.2) cannot cause a Dynamo bytecode serialization failure. The revert was a false positive caused by a pre-existing Python 3.14 compatibility bug in Dynamo's caching_precompile feature (#183712) that happened to surface because the CI job had no merge-base baseline.


@huydhn

huydhn commented May 14, 2026

Copy link
Copy Markdown
Contributor

I have disabled the test so that pt2 oncall can take a look #183810

@huydhn

huydhn commented May 14, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot drci

@huydhn

huydhn commented May 14, 2026

Copy link
Copy Markdown
Contributor

Let me land this back, give CI a bit more time to finish just in case

@huydhn

huydhn commented May 15, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

pytorchmergebot pushed a commit that referenced this pull request May 15, 2026
…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
pytorchmergebot pushed a commit that referenced this pull request May 16, 2026
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
@github-actions
github-actions Bot deleted the gh/zklaus/58/head branch June 15, 2026 02:28
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
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
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
This reverts commit 6814774.

Reverted pytorch#183700 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#183700 (comment)))
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
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
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
This reverts commit 5eb3682.

Reverted pytorch#183700 on behalf of https://github.com/huydhn due to Sorry for reverting your change but the failure is related as it is not failing in trunk ([comment](pytorch#183700 (comment)))
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
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
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…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
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
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#183700, pytorch#180237
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
This reverts commit 6814774.

Reverted pytorch#183700 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#183700 (comment)))
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
This reverts commit 5eb3682.

Reverted pytorch#183700 on behalf of https://github.com/huydhn due to Sorry for reverting your change but the failure is related as it is not failing in trunk ([comment](pytorch#183700 (comment)))
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…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
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
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#183700, pytorch#180237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/binaries Trigger all binary build and upload jobs on the PR ciflow/trunk Trigger trunk jobs on your pull request Merged no-runner-experiments Bypass Meta/LF runner determinator open source Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants