Skip to content

Add license to framework sdist builds#3002

Open
ksivaman wants to merge 1 commit into
NVIDIA:mainfrom
ksivaman:fw_build_license
Open

Add license to framework sdist builds#3002
ksivaman wants to merge 1 commit into
NVIDIA:mainfrom
ksivaman:fw_build_license

Conversation

@ksivaman
Copy link
Copy Markdown
Member

@ksivaman ksivaman commented May 17, 2026

Description

Add license to transformer-engine-torch and transformer-engine-jax PyPI packages.

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

Changes

  • Add license to transformer-engine-torch and transformer-engine-jax PyPI packages.

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

Signed-off-by: ksivamani <ksivamani@nvidia.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR adds the repo-level LICENSE file to the transformer-engine-torch and transformer-engine-jax PyPI packages by copying it into each framework's source directory at build time and registering it with setuptools via license_files.

  • The license is copied from the repo root (../../LICENSE) to the framework directory before setuptools.setup() is called, then removed afterward for sdist/bdist_wheel invocations — mirroring the existing pattern used for build_tools.
  • license_files=(\"LICENSE\",) is added to both setuptools.setup() calls so the file is correctly included in sdist and wheel distributions.

Confidence Score: 4/5

Safe to merge; the change is purely additive build infrastructure with no impact on runtime library code.

The core approach is sound. Two minor cleanup-reliability observations exist: the copy runs at module scope while the unlink is gated on main and specific argv values, and there is no try/finally around the cleanup sequence. Neither issue affects the distributed package contents.

Both transformer_engine/jax/setup.py and transformer_engine/pytorch/setup.py carry identical cleanup patterns worth a second look.

Important Files Changed

Filename Overview
transformer_engine/jax/setup.py Copies LICENSE from repo root to the JAX framework directory at module load time and registers it with setuptools via license_files; cleans up only on select build commands without a try/finally guard.
transformer_engine/pytorch/setup.py Identical license-copy pattern as the JAX setup; same module-level copy and conditional cleanup, consistent between both framework packages.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[setup.py executed] --> B{license_src.is_file?}
    B -- Yes --> C["shutil.copyfile(license_src, license_dst)\n(module scope)"]
    B -- No --> D[No license copied]
    C --> E["if __name__ == '__main__'"]
    D --> E
    E --> F["setuptools.setup(..., license_files=('LICENSE',))"]
    F --> G{"sdist / bdist_wheel\nin sys.argv?"}
    G -- Yes --> H[shutil.rmtree common_headers]
    H --> I[shutil.rmtree build_tools]
    I --> J{license_dst.is_file?}
    J -- Yes --> K[license_dst.unlink]
    J -- No --> L[Done]
    K --> L
    G -- No --> M["LICENSE left in framework dir\n(e.g. for 'install' or 'develop')"]
Loading

Reviews (1): Last reviewed commit: "Add license to framework sdist builds" | Re-trigger Greptile

Comment on lines +144 to +145
if license_dst.is_file():
license_dst.unlink()
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.

P2 Cleanup may be skipped on exception

shutil.rmtree("build_tools") runs before license_dst.unlink() with no error handling between them. If the rmtree call raises (e.g., the directory was never created because NVTE_RELEASE_BUILD was unset and build_tools_dir didn't exist), the unlink never runs and transformer_engine/jax/LICENSE is left behind in the source tree. A try/finally block would make cleanup reliable regardless of intermediate failures. The same pattern applies to transformer_engine/pytorch/setup.py.

Comment on lines +45 to +48
license_src = current_file_path.parent.parent / "LICENSE"
license_dst = current_file_path / "LICENSE"
if license_src.is_file():
shutil.copyfile(license_src, license_dst)
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.

P2 License file copied at module scope, cleanup only in __main__

The shutil.copyfile call runs unconditionally at import time (module scope), while license_dst.unlink() only executes when __name__ == "__main__" and specific build commands are in sys.argv. If any tooling inspects or imports this file without running it as __main__ (e.g., certain PEP 517 build-backend introspection steps), the LICENSE file will be copied to the framework source directory and never removed. Placing the copy inside the if __name__ == "__main__": block — mirroring how common_headers_dir is handled — would keep the lifecycle symmetric. The same issue is present in transformer_engine/pytorch/setup.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant