Add pyproject.toml with build-system metadata - #195
Conversation
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
left a comment
There was a problem hiding this comment.
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?
Summary
Adds pyproject.toml for modern build system configuration (refs #172).
Users should install with
pip install --no-build-isolation .as documented.