Skip to content

OP#9364: Preserve PEP 508 markers and support optional dependencies#2

Merged
briemla merged 10 commits intomainfrom
bug/9364-platform-specific-dependencies-cause-pip-conflicts-in-dependency-update-pre-commit-hook
Feb 16, 2026
Merged

OP#9364: Preserve PEP 508 markers and support optional dependencies#2
briemla merged 10 commits intomainfrom
bug/9364-platform-specific-dependencies-cause-pip-conflicts-in-dependency-update-pre-commit-hook

Conversation

@randy-seng
Copy link
Member

@randy-seng randy-seng commented Feb 13, 2026

OP#9364

This commit fixes two critical issues:

  1. Platform-Specific Dependencies: Platform markers (e.g., sys_platform) are now preserved in the serialized output instead of being stripped. This prevents pip conflict errors when multiple platform-specific versions of the same package exist (e.g., numpy==2.1.1 for Linux/macOS and numpy==1.26.4 for Windows).

  2. Optional Dependencies: Added --optional-extras argument to include packages from [project.optional-dependencies] in type checking. This is essential for projects that unconditionally import packages defined as optional extras.

Changes:

  • Add packaging>=24.0 dependency for PEP 508 requirement parsing
  • Add marker property to Package abstract class and implementations
  • Create parse_requirement_with_marker() function using packaging.requirements
  • Update Package.hash() and eq() to include marker
  • Add parse_optional_dependencies() to parse specified extras
  • Add get_extra_index_urls() to auto-detect extra index URLs from uv config
  • Update parse_pyproject_toml() to accept optional_extras parameter
  • Add --optional-extras CLI argument to main()
  • Update all package creation functions to accept marker parameter
  • Add comprehensive tests for marker preservation and optional deps
  • Update README with usage examples

Breaking Changes: None (backward compatible)
Version Bump: 0.1.0 -> 0.2.0 (minor)

This commit fixes two critical issues:

1. Platform-Specific Dependencies: Platform markers (e.g., sys_platform)
   are now preserved in the serialized output instead of being stripped.
   This prevents pip conflict errors when multiple platform-specific
   versions of the same package exist (e.g., numpy==2.1.1 for Linux/macOS
   and numpy==1.26.4 for Windows).

2. Optional Dependencies: Added --optional-extras argument to include
   packages from [project.optional-dependencies] in type checking. This
   is essential for projects that unconditionally import packages defined
   as optional extras.

Changes:
- Add packaging>=24.0 dependency for PEP 508 requirement parsing
- Add marker property to Package abstract class and implementations
- Create parse_requirement_with_marker() function using packaging.requirements
- Update Package.__hash__() and __eq__() to include marker
- Add parse_optional_dependencies() to parse specified extras
- Add get_extra_index_urls() to auto-detect extra index URLs from uv config
- Update parse_pyproject_toml() to accept optional_extras parameter
- Add --optional-extras CLI argument to main()
- Update all package creation functions to accept marker parameter
- Add comprehensive tests for marker preservation and optional deps
- Update README with usage examples

Breaking Changes: None (backward compatible)
Version Bump: 0.1.0 -> 0.2.0 (minor)
@randy-seng randy-seng requested a review from briemla February 13, 2026 18:07
@briemla briemla merged commit 24c028d into main Feb 16, 2026
10 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.

2 participants