Skip to content

Add pyproject.toml with build-system metadata - #195

Open
Functionhx wants to merge 1 commit into
deepseek-ai:mainfrom
Functionhx:build/pyproject-toml
Open

Add pyproject.toml with build-system metadata#195
Functionhx wants to merge 1 commit into
deepseek-ai:mainfrom
Functionhx:build/pyproject-toml

Conversation

@Functionhx

Copy link
Copy Markdown

Summary

Adds pyproject.toml for modern build system configuration (refs #172).

  • build-system declares setuptools>=61.0 (torch intentionally omitted — pip isolated build would pull CPU-only wheel)
  • Runtime dependency on torch declared in project.dependencies
  • Version management: _version.py as single source of truth, setup.py reads via exec() to avoid circular import
  • setup.py preserved for CUDA extension compilation logic

Users should install with pip install --no-build-isolation . as documented.

Migrate build configuration to pyproject.toml while keeping setup.py
for the complex CUDA extension build logic.

Changes:
- pyproject.toml: declare setuptools build backend, project metadata,
  torch runtime dependency. Version marked as dynamic (computed in
  setup.py). torch intentionally NOT in build-system.requires because
  pip's isolated build would pull CPU-only wheel; CUDA torch must be
  pre-installed.
- flash_mla/_version.py: single source of truth for base version
- flash_mla/__init__.py: uses importlib.metadata.version() at runtime
  to match installed package version (git hash suffix), falling back
  to static base from _version.py for dev/uninstalled usage
- setup.py: reads base version from _version.py via exec() (file I/O)
  to avoid importing the flash_mla package, whose __init__.py imports
  the C extension that does not exist at build time. [tool.setuptools.dynamic]
  is intentionally omitted for the same reason.

Test Plan:
- Validated TOML syntax with pip's bundled tomli parser
- Verified exec() version reading works in isolation
- Confirmed no Python import of flash_mla package during build

Signed-off-by: Yuchen Fan <functionhx@gmail.com>

@bvolpato bvolpato left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we reconcile isolated build config with setup.py importing Torch? pip install -v . now creates an environment with only setuptools, then fails during metadata generation with ModuleNotFoundError: No module named 'torch'. Would it make sense to provide a viable build requirement strategy, or update install path here and in README to require --no-build-isolation?

Should runtime dependency also be torch>=2.0 to match documented minimum? Otherwise existing Torch 1.x install satisfies metadata even though it is unsupported.

One smaller versioning question: when importing a source checkout with another flash_mla distribution installed, importlib.metadata.version("flash_mla") reports installed distribution version. Could source checkouts use _version.py directly so diagnostics match code being imported?

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