Skip to content

Conversation

@dhellmann
Copy link
Member

Save the constraints used during bootstrapping to the graph file so they are available when debugging later.

Update the graph commands explain-duplicates and why to include the constraint information, when it is present in the graph file.

Chat transcript: https://gist.github.com/dhellmann/804bb6128189e8585adfdfba97d70326

Closes #813

Co-authored-by: Claude 3.5 Sonnet (Anthropic AI Assistant) via Cursor

Add constraint field to dependency graph nodes to record which
constraint rules were applied to each package during the build.
This makes it easier to understand and debug builds by preserving
the constraint information that influenced version resolution.

Changes:
- Add constraint field to DependencyNode and DependencyNodeDict
- Update add_dependency() to accept and store constraint parameter
- Modify bootstrapper to retrieve and pass constraint rules
- Update bootstrap command to include constraints for top-level deps
- Maintain backward compatibility for loading old graph files
- Update tests to include constraint field in assertions

The constraint field defaults to an empty string when no constraint
is applied, and old graph files without this field can still be
loaded successfully.

Closes: python-wheel-build#813

Chat transcript: https://gist.github.com/dhellmann/804bb6128189e8585adfdfba97d70326

Co-authored-by: Claude 3.5 Sonnet (Anthropic AI Assistant) via Cursor
Signed-off-by: Doug Hellmann <[email protected]>
Update graph subcommands to show constraint information when analyzing
dependencies, making it easier to understand which constraints influenced
version selection during builds.

Changes to explain-duplicates:
- Show constraint once at package name level (not per-version)
- Constraint from first node used since all versions share same constraint
- Results in cleaner, less repetitive output

Changes to why command:
- Show constraint for queried package at depth 0
- Show constraint for parent packages in dependency relationships
- Show constraint for top-level dependencies

Example output for explain-duplicates:
  package-b (constraint: package-b>=1.0,<2.0)
    1.0.0
    2.0.0

Example output for why command:
  child-pkg==1.5.0 (constraint: child-pkg>=1.0,<2.0)
   * child-pkg==1.5.0 is an install dependency of parent-pkg==1.0.0 (constraint: parent-pkg==1.0.0)
   * toplevel-pkg==2.0.0 (constraint: toplevel-pkg>=2.0,<3.0) is a toplevel dependency

Added comprehensive test coverage for both commands with and without
constraints to ensure graceful handling of all scenarios.

Chat transcript: https://gist.github.com/dhellmann/804bb6128189e8585adfdfba97d70326

Co-authored-by: Claude 3.5 Sonnet (Anthropic AI Assistant) via Cursor
Signed-off-by: Doug Hellmann <[email protected]>
@dhellmann dhellmann requested a review from a team as a code owner October 25, 2025 14:58
@mergify mergify bot added the ci label Oct 25, 2025
Copy link
Contributor

@rd4398 rd4398 left a comment

Choose a reason for hiding this comment

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

Nice, this looks good!

@mergify mergify bot merged commit bf50cab into python-wheel-build:main Oct 27, 2025
111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save constraint rules in graph file

2 participants