ITADN

Migrate to PEP 735 dependency groups

#146Pull Requesteliotwrobson 创建于 2026-01-15
E
eliotwrobsoncommented
## Summary This PR implements support for PEP 735 dependency groups in the pyos-package-template, addressing issue #143. ## Changes Made ### 1. Updated `template/pyproject.toml.jinja` - Added conditional logic to use `[dependency-groups]` when `use_hatch_envs=True` - Kept `[project.optional-dependencies]` for backward compatibility when `use_hatch_envs=False` - Moved all development dependencies (dev, docs, build, tests, style, types) to the new `[dependency-groups]` section - Added `twine` to the dependency-groups build section ### 2. Updated Hatch Environments - Changed all hatch environments from `features = [...]` to `dependency-groups = [...]` - Added `builder = true` to the build environment (required for Hatch 1.16+) - Added explicit `dependencies = ["twine"]` to build environment as a workaround for dependency-groups not being installed in builder environments (see pypa/hatch#2152) - Updated environments: build, test, docs, style, audit, and types ### 3. Added Tests - Created `test_hatch_deps_groups()` to verify dependency-groups are properly configured when using hatch environments - Updated `test_template_suite()` to use `hatch run build:check` instead of `hatch build --clean` and explicitly enable hatch environments ### 4. Updated Documentation - Updated `CHANGELOG.md` with comprehensive notes about the migration - Documented the requirement for Hatch 1.16+ - Explained backward compatibility when `use_hatch_envs=False` ## Key Benefits ✅ **Standards-compliant**: Uses PEP 735 dependency groups instead of tool-specific optional-dependencies ✅ **Less tool lock-in**: Makes the template less attached to Hatch-specific configuration ✅ **Forward-compatible**: Leverages the newly released Hatch 1.16 support for dependency groups ✅ **Backward-compatible**: Maintains optional-dependencies when not using Hatch environments ## Testing - Added new test `test_hatch_deps_groups()` that validates the dependency-groups configuration - Updated existing test to use the new build environment command ## Notes - Requires Hatch 1.16+ for full functionality - When `use_hatch_envs=False`, the template continues to use `[project.optional-dependencies]` for backward compatibility Fixes #143 cc @mathematicalmichael @Midnighter @sneakers-the-rat
合并状态:未合并 关闭于 2026-01-15 1 条评论