Skip to content

[build]: flatten ktransformers package shim#1955

Merged
JimmyPeilinLi merged 1 commit intomainfrom
flatten-ktransformers-shim
Apr 25, 2026
Merged

[build]: flatten ktransformers package shim#1955
JimmyPeilinLi merged 1 commit intomainfrom
flatten-ktransformers-shim

Conversation

@JimmyPeilinLi
Copy link
Copy Markdown
Collaborator

@JimmyPeilinLi JimmyPeilinLi commented Apr 25, 2026

Message:

Flatten the minimal top-level ktransformers import shim from a package directory to a single ktransformers.py module.

Scope:

  • Move ktransformers/__init__.py to ktransformers.py.
  • Switch setuptools packaging from packages = ["ktransformers"] to py-modules = ["ktransformers"].
  • Keep the existing ktransformers distribution metadata and dependency/extras logic unchanged.

Why:

  • Avoid keeping a root-level ktransformers/ source directory next to kt-kernel/.
  • Preserve pip install ktransformers and import ktransformers behavior.

Validation:

  • Built the top-level ktransformers wheel locally on sapphire4 from commit d143cf3.
  • Verified wheel contents contain ktransformers.py and no ktransformers/ package directory.
  • Verified METADATA keeps kt-kernel==0.6.1, [sft], and [sglang] dependencies.
  • Installed the wheel into a clean local venv with --no-deps and verified import ktransformers, __version__ == 0.6.1, distribution version 0.6.1, and hasattr(ktransformers, "__path__") == False.
  • No PyPI publish.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the project structure by changing the top-level package to a module and updating the build configuration in pyproject.toml. Additionally, it improves the version reading logic in ktransformers.py. I have reviewed the changes and suggest explicitly specifying the encoding when reading the version file to ensure cross-platform compatibility.

Comment thread ktransformers.py
exec((Path(__file__).resolve().parents[1] / 'version.py').read_text(), ns)
return ns['__version__']
version_file = Path(__file__).resolve().with_name("version.py")
exec(version_file.read_text(), ns)
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.

medium

It is recommended to specify an encoding (e.g., encoding="utf-8") when calling read_text(). This ensures consistent behavior across different platforms and locales, especially on Windows where the default system encoding might not be UTF-8, potentially leading to issues if the file contains non-ASCII characters.

Suggested change
exec(version_file.read_text(), ns)
exec(version_file.read_text(encoding="utf-8"), ns)

@JimmyPeilinLi JimmyPeilinLi merged commit 07e2744 into main Apr 25, 2026
6 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.

1 participant