Skip to content

Comments

Fix build_tools missing from sdist causing uv cached installs to fail#2684

Merged
ptrendx merged 1 commit intoNVIDIA:mainfrom
hemildesai:hemil/fix-sdist-build-tools
Feb 17, 2026
Merged

Fix build_tools missing from sdist causing uv cached installs to fail#2684
ptrendx merged 1 commit intoNVIDIA:mainfrom
hemildesai:hemil/fix-sdist-build-tools

Conversation

@hemildesai
Copy link
Contributor

@hemildesai hemildesai commented Feb 15, 2026

Change

  • Include build_tools/ in the source distribution via MANIFEST.in so that cached builds from uv (and pip) can resolve setup.py's top-level imports

setup.py imports from build_tools at the top level:

from build_tools.build_ext import CMakeExtension, get_build_ext
from build_tools.te_version import te_version
from build_tools.utils import cuda_archs, cuda_version, ...

The __legacy__ build backend in pyproject.toml adds the source root to sys.path, so these imports work when building directly from the source tree. However, build_tools/ is not included in the sdist because:

  1. MANIFEST.in did not list it
  2. build_tools/ is not discovered by find_packages() (it's a standalone directory at the repo root, not under transformer_engine/)

When uv caches the sdist and later builds a wheel from it, the sdist is extracted to a temporary directory where build_tools/ is absent, causing a ModuleNotFoundError. Passing --no-cache to uv works around this by forcing a fresh build from the full source tree.

Added build_tools to MANIFEST.in:

 recursive-include transformer_engine/common/include *.*
+recursive-include build_tools *.py *.txt
  • python setup.py sdist produces a tarball that contains build_tools/
$ tar tzf dist/transformer_engine-*.tar.gz | grep build_tools
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/VERSION.txt
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/__init__.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/build_ext.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/jax.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/pytorch.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/te_version.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/utils.py

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…fail

- Include `build_tools/` in the source distribution via `MANIFEST.in` so that cached builds from `uv` (and `pip`) can resolve `setup.py`'s top-level imports

`setup.py` imports from `build_tools` at the top level:

```python
from build_tools.build_ext import CMakeExtension, get_build_ext
from build_tools.te_version import te_version
from build_tools.utils import cuda_archs, cuda_version, ...
```

The `__legacy__` build backend in `pyproject.toml` adds the source root to `sys.path`, so these imports work when building directly from the source tree. However, `build_tools/` is not included in the sdist because:

1. `MANIFEST.in` did not list it
2. `build_tools/` is not discovered by `find_packages()` (it's a standalone directory at the repo root, not under `transformer_engine/`)

When `uv` caches the sdist and later builds a wheel from it, the sdist is extracted to a temporary directory where `build_tools/` is absent, causing a `ModuleNotFoundError`. Passing `--no-cache` to `uv` works around this by forcing a fresh build from the full source tree.

Added `build_tools` to `MANIFEST.in`:

```diff
 recursive-include transformer_engine/common/include *.*
+recursive-include build_tools *.py *.txt
```

- [x] `python setup.py sdist` produces a tarball that contains `build_tools/`

```
$ tar tzf dist/transformer_engine-*.tar.gz | grep build_tools
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/VERSION.txt
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/__init__.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/build_ext.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/jax.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/pytorch.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/te_version.py
transformer_engine-2.13.0.dev0+82f7ebeb/build_tools/utils.py
```

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Hemil Desai <hemild@nvidia.com>
@hemildesai hemildesai force-pushed the hemil/fix-sdist-build-tools branch from d4c822c to 1f64a2e Compare February 15, 2026 23:55
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 15, 2026

Greptile Summary

This PR fixes a build bug where uv (and pip) cached sdist installs would fail with a ModuleNotFoundError because build_tools/ was missing from the source distribution.

  • setup.py imports from build_tools at the top level (build_ext, te_version, utils), but build_tools/ was never included in the sdist — it wasn't listed in MANIFEST.in and isn't discovered by find_packages() since it sits at the repo root, not under transformer_engine/.
  • The fix adds recursive-include build_tools *.py *.txt to MANIFEST.in, which captures all Python source files and VERSION.txt (read by te_version.py at build time).
  • The wheel_utils/ subdirectory (Dockerfiles, shell scripts) is correctly excluded since those are only used for CI/CD wheel building, not by setup.py.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-scoped build infrastructure fix with no functional code changes.
  • The change is a single line addition to MANIFEST.in that correctly includes the build_tools/ directory in the sdist. The *.py *.txt pattern covers exactly the files needed by setup.py during builds. There are no code logic changes, no new dependencies, and no risk of regression.
  • No files require special attention.

Important Files Changed

Filename Overview
MANIFEST.in Adds recursive-include build_tools *.py *.txt to include the build_tools/ package in the source distribution, fixing ModuleNotFoundError when building from cached sdists (e.g., with uv). The *.py *.txt pattern covers all files needed by setup.py.

Flowchart

flowchart TD
    A["uv/pip install transformer_engine"] --> B["Build sdist from source tree"]
    B --> C["Cache sdist tarball"]
    C --> D["Extract sdist to temp directory"]
    D --> E{"build_tools/ present?"}
    E -->|"Before fix: No"| F["ModuleNotFoundError\nsetup.py cannot import build_tools"]
    E -->|"After fix: Yes"| G["setup.py imports build_tools successfully"]
    G --> H["Build wheel from sdist"]
    H --> I["Install wheel"]
Loading

Last reviewed commit: 1f64a2e

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ptrendx ptrendx merged commit fa68781 into NVIDIA:main Feb 17, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants