Skip to content

Fix extra incorrectly shown on installation error#13659

Open
sepehr-rs wants to merge 20 commits intopypa:mainfrom
sepehr-rs:fix-extras
Open

Fix extra incorrectly shown on installation error#13659
sepehr-rs wants to merge 20 commits intopypa:mainfrom
sepehr-rs:fix-extras

Conversation

@sepehr-rs
Copy link
Copy Markdown
Member

@sepehr-rs sepehr-rs commented Nov 20, 2025

Fixes #13618
This resolves the issue, though I’m not certain it’s the ideal place for the fix. If needed, we can move the solution further down in the stack.

@notatallshaw
Copy link
Copy Markdown
Member

notatallshaw commented Nov 21, 2025

I've not spent any time looking at the code, but I would be pretty nervous about removing the marker information until right before the error message.

Even if that marker information isn't used now someone might want to use it later and be surprised to find all marker information stripped, and there's no comment as to why that happened.

@sepehr-rs
Copy link
Copy Markdown
Member Author

I've not spent any time looking at the code, but I would be pretty nervous about removing the marker information until right before the error message.

Even if that marker information isn't used now someone might want to use it later and be surprised to find all marker information stripped, and there's no comment as to why that happened.

Thanks for the review, @notatallshaw!
I moved the change further down so the marker info is preserved internally and only stripped at error-message time.

@notatallshaw notatallshaw added this to the 26.0 milestone Nov 30, 2025
@ichard26 ichard26 requested a review from notatallshaw January 11, 2026 20:09
Copy link
Copy Markdown
Member

@notatallshaw notatallshaw left a comment

Choose a reason for hiding this comment

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

Update the test test_install_special_extra in tests/functional/test_install_extras.py to include something like this at the end:

    assert "No matching distribution found for missing_pkg" in result.stderr, str(result)
    assert "extra ==" not in result.stderr, str(result)

Then I think you're going to find two situations you're not handeling right now:

  1. When the requirement has a parent, you need to move your string manipulation to the top of _report_single_requirement_conflict so it also gets applied to the req_disp variable for logging
  2. The logging and raising of raise DistributionNotFound in PackagingFinder.find_requirement in src/pip/_internal/index/package_finder.py

@notatallshaw
Copy link
Copy Markdown
Member

I'm realizing I wrote the above comment in a bit of a rush and I've not verified the output is actually misleading in that test. So feel free to correct me if I made a mistake, I'll take a other look in the next few days when I have time to review again.

@notatallshaw
Copy link
Copy Markdown
Member

I'm going to move this to 26.1 milestone, I'm generally happy with this approach, but it needs tests, either as new or modified existing ones, and I don't see a rush to get it out (this error has been confusing for a long time).

@notatallshaw notatallshaw modified the milestones: 26.0, 26.1 Jan 28, 2026
@sepehr-rs
Copy link
Copy Markdown
Member Author

Hi @notatallshaw, thanks for the review. Sorry for the delay. I’ve updated the code and tests based on your feedback. Would appreciate another look when you have a moment.
Thanks again!

Copy link
Copy Markdown
Contributor

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

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

Not a pip developer, but hopefully some helpful review comments...

Also this needs more tests I think, right now it seems that only one of the two modified paths is tested?

Comment thread tests/functional/test_install_extras.py
Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Comment thread src/pip/_internal/index/package_finder.py Outdated
@sepehr-rs
Copy link
Copy Markdown
Member Author

Hi @danielhollas, thanks a lot for the helpful review! I've addressed your comments, but I’m not entirely clear on your note about the assertion test. Could you clarify what you meant?

Copy link
Copy Markdown
Contributor

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

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

@sepehr-rs thanks. You can disregard my test assertion comment, but I think there's still an issue with how you override req_disp variable.

Comment on lines +670 to +671
req_disp = re.sub(r';\s*extra\s*==\s*".*?"', "", str(req)).strip()
req_str = req_disp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is still wrong as it overrides the req_disp set above.

Suggested change
req_disp = re.sub(r';\s*extra\s*==\s*".*?"', "", str(req)).strip()
req_str = req_disp
req_disp = re.sub(r';\s*extra\s*==\s*".*?"', "", req_disp).strip()

)

return DistributionNotFound(f"No matching distribution found for {req}")
return DistributionNotFound(f"No matching distribution found for {req_str}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of defining req_str perhaps it makes sense to just use req_disp here? It's already used above for logging.

@notatallshaw
Copy link
Copy Markdown
Member

I took a quick look at this danielhollas's comments all look correct to me.

@sepehr-rs
Copy link
Copy Markdown
Member Author

Hi, sorry for the delay. Things have been hectic over here in Iran and I only recently got access to GitHub again. I’ve committed the changes proposed by @danielhollas. Please let me know what you think!

@notatallshaw notatallshaw modified the milestones: 26.1, 26.2 Apr 24, 2026
@notatallshaw
Copy link
Copy Markdown
Member

Sorry, I think this PR still needs some more review and work, but I'm very unlikely to have time to review before 26.1.

Copy link
Copy Markdown
Contributor

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

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

Things have been hectic over here in Iran and I only recently got access to GitHub again.

Oof, what an understatement, I am very sorry. :-(

Thank you for the changes, I think that there is at least one thing that needs fixing, otherwise looks reasonable to me, but I am not a pip maintainer, just trying to help with a review :-)

Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Comment thread src/pip/_internal/index/package_finder.py Outdated
Comment thread src/pip/_internal/resolution/resolvelib/factory.py Outdated
Co-authored-by: Daniel Hollas <danekhollas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extra incorrectly shown on installation error

3 participants