Skip to content

Ship all git-tracked files in the sdist - #190192

Closed
zklaus wants to merge 13 commits into
gh/zklaus/61/basefrom
gh/zklaus/61/head
Closed

zklaus wants to merge 13 commits into
gh/zklaus/61/basefrom
gh/zklaus/61/head

Conversation

@zklaus

@zklaus zklaus commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in .pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"
.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

Test plan

  • sdist file list matches git ls-files --recurse-submodules
    exactly, up to (a) the 1323 deliberately excluded files above and
    (b) 4 unicode-quoting artifacts of the listing comparison itself,
    with zero .git pointers, bytecode, third_party/nccl content, or
    symlink members:
    uv build --sdist --out-dir dist
    git ls-files --recurse-submodules | sort > /tmp/git-files.txt
    tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
    comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
    grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
    tar tvzf dist/torch-*.tar.gz | grep -c '^l'
    
  • From-sdist build works end to end (CPU-only, linux-x86_64):
    pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
    python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
    /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
    
  • Superset of the setuptools sdist's tracked content: compared
    against a python setup.py sdist tarball built from main
    (7de45b6), zero tracked files are present there but missing here;
    the ~480 tracked files only present here are ones MANIFEST.in dropped
    as collateral (submodule .gitignore/.gitmodules via global-exclude .git*, flatbuffers test data lost to a setuptools symlink-walk
    quirk).
  • include/exclude interaction verified against scikit-build-core
    1.0.3's collector with a synthetic tree, including the counterfactual
    configs (negation-only and exclude-only both leak files; the pairing
    is required).
  • No remaining consumers of MANIFEST.in:
    grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
    

Co-Generated with Claude Code

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 758efc2 with merge base bfe58eb (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 16, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: 51f8c7c
Pull-Request: #190192
@Skylion007
Skylion007 requested a review from Copilot July 16, 2026 16:20
Comment thread pyproject.toml
# strings) to inject CUDA/ROCm/XPU pip package dependencies into the wheel.
provider = { path = "tools/metadata", module = "dependencies" }

[tool.scikit-build.sdist]

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.

We generate some files with CMake (like various headers), should we add cmake=True key here? Also useful for any external_fetched repos by cmake? Might inflate the sdist wheel size so please check.

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.

Actually not sure how to make sure generated files are included or shoils they be, there is sdist.include = ["generated/foo.h"] but I dont see a way to force it run specific targets.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd prefer to keep cmake=False (the default) here. An sdist should ship sources, not build products -- and we've verified it's complete as-is: the test plan builds a working wheel from this sdist on a clean machine, so every CMake-generated file (codegen from native_functions.yaml, version.h, etc.) is regenerated at wheel-build time from sources the sdist already contains. Turning on cmake=True would run a full configure at sdist time (minutes, toolchain-dependent, and it'd bake environment-specific results into a portable artifact), and as you note risks inflating size. CMake-fetched externals are intentionally out of scope for the same reason we exclude third_party/nccl -- they're downloaded at build time, and snapshotting a fetch into the sdist would pin them incorrectly. And you're right that there's no clean way to force specific targets to run for sdist collection, which is another reason to keep this to sources.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts PyTorch’s source distribution (sdist) contents under the scikit-build-core backend to ensure git-tracked third-party sources are not silently dropped due to gitignore-based collection, and removes the now-inert MANIFEST.in.

Changes:

  • Add [tool.scikit-build.sdist] include/exclude rules to force-include otherwise-gitignored-but-tracked vendored sources while pruning CI/plumbing paths.
  • Remove MANIFEST.in, whose behavior is replaced by the scikit-build-core configuration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Adds scikit-build-core sdist include/exclude rules to restore vendored sources otherwise dropped by gitignore semantics.
MANIFEST.in Removes the legacy setuptools sdist manifest file.

Comment thread pyproject.toml Resolved
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 17, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 61603b4
Pull-Request: #190192
@Skylion007

Copy link
Copy Markdown
Collaborator

Does this properly handle submodule? Do we have tests that try to build the sdist? The explicit inclusion option using manifest.in feels like it would be the minimal change first, unless
Manifest.in is wrong...

[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 19, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 4c5c2e6
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 20, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 0c86caf
Pull-Request: #190192
@zklaus

zklaus commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

Does this properly handle submodule? Do we have tests that try to build the sdist? The explicit inclusion option using manifest.in feels like it would be the minimal change first, unless Manifest.in is wrong...

Good questions:

Submodules -- yes, handled. The comparison baseline throughout was git ls-files --recurse-submodules, and the fixed sdist matches it exactly (modulo the deliberate plumbing exclusions). Concretely, the whole reason this PR exists is that submodule sources were being dropped: scikit-build-core's sdist walk applies gitignore semantics, so vendored trees whose own .gitignore matches committed files (XNNPACK's gen/ microkernels, all of oneDNN's *.cpp via ideep, protobuf's *.pb.cc, clog under qnnpack deps/) were silently omitted -- ~11,500 tracked files, leaving an unbuildable sdist. The third_party/** include restores them.

sdist build test -- verified manually, not yet automated. The commit's test plan (a) diffs the sdist filelist against git ls-files --recurse-submodules (zero unexplained delta; no .git/bytecode/nccl leakage; no symlink members), and (b) does a full from-sdist build end-to-end: pip wheel the tarball, install into a fresh venv, then import torch + matmul + torch.compile, on a clean machine. A CI job that builds the sdist would be a reasonable follow-up, but felt out of scope for this fix.

Why not MANIFEST.in -- it genuinely is dead here: scikit-build-core's native backend doesn't read it at all (it's a setuptools/distutils mechanism, and we switched backends in #180247), which is why this PR removes it. So [tool.scikit-build.sdist] is the equivalent-and-only knob, not an added layer on top of MANIFEST.in. Compared against a setup.py sdist from main, this sdist is a strict superset of the tracked content -- nothing the old MANIFEST.in shipped is lost.

@zklaus zklaus added the topic: not user facing topic category label Jul 20, 2026
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 20, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 8f2805e
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 20, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: f723613
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 21, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 7bdc6da
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 21, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: a30f9ff
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 21, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 1c34e92
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 21, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 322b0c1
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 22, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: b8e7c83
Pull-Request: #190192
[ghstack-poisoned]
zklaus added a commit that referenced this pull request Jul 22, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)

ghstack-source-id: 55b51a7
Pull-Request: #190192

@albanD albanD 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.

Sounds fair as an update.
We should have a follow up clarifying what we expect users to do with these sdist and test it.

@zklaus

zklaus commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 23, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 2 jobs have failed, first few of them are: trunk / win-vs2022-cpu-py3 / test (default, 2, 4, windows.4xlarge.nonephemeral), trunk / win-vs2022-cpu-py3 / test (default, 4, 4, windows.4xlarge.nonephemeral)

Details for Dev Infra team Raised by workflow job

@zklaus

zklaus commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

mlazos pushed a commit that referenced this pull request Jul 25, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: #190192
Approved by: https://github.com/albanD, https://github.com/atalman
ghstack dependencies: #180248
Harsha0Sree pushed a commit to Harsha0Sree/pytorch that referenced this pull request Jul 25, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (pytorch#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: pytorch#190192
Approved by: https://github.com/albanD, https://github.com/atalman
ghstack dependencies: pytorch#180248
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (pytorch#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: pytorch#190192
Approved by: https://github.com/albanD, https://github.com/atalman
ghstack dependencies: pytorch#180248
MelindaTan pushed a commit to MelindaTan/pytorch that referenced this pull request Jul 31, 2026
scikit-build-core collects sdist contents by walking the tree with
gitignore semantics rather than from git tracking. Several vendored
trees commit files that their own .gitignore matches (XNNPACK's
generated microkernels under gen/, all oneDNN C++ sources via ideep's
"*.cpp" pattern, protobuf's checked-in *.pb.cc, clog under qnnpack's
deps/), and PyTorch's top-level .gitignore patterns (bare "gen",
"*.pb.h") also match tracked third-party files. The walk therefore
silently dropped ~11,500 tracked files, leaving an sdist that cannot
build: XNNPACK, oneDNN, cpuinfo, and NNPACK codegen all lack sources.
The legacy setup.py sdist never hit this because MANIFEST.in grafts
copy from disk regardless of gitignore.

Fix: re-include the affected roots via [tool.scikit-build.sdist]. In
scikit-build-core's collector, include matches take precedence over
every exclude source (user excludes, built-ins, gitignore), so a
separate sdist.exclude list cannot trim a blanket include; entries that
must not ship despite the blanket include are negated inside the
include list and then caught by an exclude source (see the comment in
pyproject.toml for the exact mechanics). The natural alternative --
collecting the file list from git tracking -- does not exist in
scikit-build-core today; worth proposing upstream, at which point this
block can go away.

Deliberately excluded (1323 tracked files, matching the legacy
MANIFEST.in's intent): repo/CI plumbing (.github, .ci, .claude, .spin,
vendored .github dirs) and unneeded vendored language bindings
(flatbuffers java/kotlin, ittapi rust). The latter were pruned by
MANIFEST.in (pytorch#157814) to work around invalid symlinks in those trees;
under scikit-build-core the default sdist.resolve-symlinks="all" would
instead silently duplicate the link targets into the sdist. With these
prunes the sdist contains no symlink members at all; the handful of
remaining tracked symlinks (AGENTS.md, docs/requirements.txt, ...)
dereference to a few KB of duplicated content.

MANIFEST.in itself is removed: scikit-build-core's native backend
never reads it, so it has been inert since the backend switch and its
sdist role is fully replaced by the configuration added here.

## Test plan

- [x] sdist file list matches `git ls-files --recurse-submodules`
  exactly, up to (a) the 1323 deliberately excluded files above and
  (b) 4 unicode-quoting artifacts of the listing comparison itself,
  with zero .git pointers, bytecode, third_party/nccl content, or
  symlink members:
  ```
  uv build --sdist --out-dir dist
  git ls-files --recurse-submodules | sort > /tmp/git-files.txt
  tar tzf dist/torch-*.tar.gz | sed 's|^[^/]*/||' | grep -v '/$' | sort > /tmp/sdist-files.txt
  comm -23 /tmp/git-files.txt /tmp/sdist-files.txt
  grep -cE '\.git$|\.pyc$|__pycache__|^third_party/nccl/|(^|/)\.github/|^\.ci/|^\.claude/|^\.spin/' /tmp/sdist-files.txt
  tar tvzf dist/torch-*.tar.gz | grep -c '^l'
  ```
- [x] From-sdist build works end to end (CPU-only, linux-x86_64):
  ```
  pip wheel dist/torch-*.tar.gz --no-deps -w /tmp/wheels
  python -m venv /tmp/venv && /tmp/venv/bin/pip install /tmp/wheels/torch-*.whl numpy
  /tmp/venv/bin/python -c "import torch; a=torch.randn(64,64); print(([email protected]).shape); print(torch.compile(lambda x: x.sin()+1)(torch.randn(8)).shape)"
  ```
- [x] Superset of the setuptools sdist's tracked content: compared
  against a `python setup.py sdist` tarball built from main
  (7de45b6), zero tracked files are present there but missing here;
  the ~480 tracked files only present here are ones MANIFEST.in dropped
  as collateral (submodule .gitignore/.gitmodules via `global-exclude
  .git*`, flatbuffers test data lost to a setuptools symlink-walk
  quirk).
- [x] include/exclude interaction verified against scikit-build-core
  1.0.3's collector with a synthetic tree, including the counterfactual
  configs (negation-only and exclude-only both leak files; the pairing
  is required).
- [x] No remaining consumers of MANIFEST.in:
  ```
  grep -rln "MANIFEST.in" --exclude-dir=third_party --exclude-dir=.git .
  ```

Co-Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: pytorch#190192
Approved by: https://github.com/albanD, https://github.com/atalman
ghstack dependencies: pytorch#180248
@github-actions
github-actions Bot deleted the gh/zklaus/61/head branch August 24, 2026 02:08
pytorchmergebot pushed a commit that referenced this pull request Sep 22, 2026
Fixes #152532.

Since #146073 NCCL is not a submodule but cloned at configure time from a tag in `.ci/docker/ci_commit_pins/nccl*.txt`. Neither release source artifact has ever shipped those files: the plain tarball strips `.ci` (since #63022, no recorded reason) and the PEP 517 sdist excludes it (#190192). A survey of all 16 archives from v2.7.0 to v2.14.0 confirms this; what varies is only whether `third_party/nccl` is present. The 2.14.0 sdist is the first artifact since 2.7.x with neither, because #190192 also stopped shipping the pre-cloned NCCL tree (deliberately: a snapshot freezes the default pin even where the cu126 pin applies). Configure then fails in `cmake/External/nccl.cmake` with ExternalProject's "No download info given for 'nccl_external'", which names neither cause nor remedy.

Two commits:

1. The two pin files join the sdist include list, so an sdist build clones NCCL exactly like a git checkout does, with the CUDA-version-specific pin honoured. The pre-build step now warns when neither the NCCL sources nor a pin exist, and `nccl.cmake` fails with a message naming the ways out (provide the sources, `USE_SYSTEM_NCCL=1`, or `USE_NCCL=0`). The fatal check lives in `nccl.cmake` rather than the pre-build step because the latter runs before CUDA is decided; a CPU-only build from a pin-less tree keeps working.
2. The release workflow copies the same two files back into the plain tarball after the `.ci` strip, so both artifacts carry the pins and nothing else from `.ci`. The pre-cloned `third_party/nccl` stays: the tarball exists for offline, complete-source builds.

Official wheels use system NCCL, so pip users are unaffected; this is for people building from the source archives. Small enough to cherry-pick into a 2.14 patch release.

Offered for this PR if wanted: a check in the pre-build step that compares an existing `third_party/nccl` (its `makefiles/version.mk`) against the selected pin and warns on mismatch. That is what would make a cu126 build from the plain tarball notice it got the default NCCL, and it also catches a developer checkout whose clone predates a pin bump. Left out for now to keep the change minimal.

Follow-up, separate PR: move the pins out of `.ci` next to `third_party/eigen_pin.txt`, which makes both include exceptions above unnecessary. It touches `install_nccl.sh` and five Dockerfiles under `.ci/docker`, so it forces a Docker image rebuild and should ride the next planned one.

Test plan: see the commit messages. sdist built from this tree contains exactly `nccl.txt` and `nccl-cu126.txt` under `.ci`, byte-identical to the tree, and no `third_party/nccl`; the CMake behaviour was driven through a minimal project in a fake source tree for all five cases; the tarball staging lines were run against a mock tree. Not exercised: the release workflow itself (release tags and nightly only) and an end-to-end CUDA build from the sdist.

Pull Request resolved: #197544
Approved by: https://github.com/atalman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants