[build]: flatten ktransformers package shim#1955
Conversation
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
| exec(version_file.read_text(), ns) | |
| exec(version_file.read_text(encoding="utf-8"), ns) |
Message:
Flatten the minimal top-level
ktransformersimport shim from a package directory to a singlektransformers.pymodule.Scope:
ktransformers/__init__.pytoktransformers.py.packages = ["ktransformers"]topy-modules = ["ktransformers"].ktransformersdistribution metadata and dependency/extras logic unchanged.Why:
ktransformers/source directory next tokt-kernel/.pip install ktransformersandimport ktransformersbehavior.Validation:
ktransformerswheel locally on sapphire4 from commitd143cf3.ktransformers.pyand noktransformers/package directory.kt-kernel==0.6.1,[sft], and[sglang]dependencies.--no-depsand verifiedimport ktransformers,__version__ == 0.6.1, distribution version0.6.1, andhasattr(ktransformers, "__path__") == False.