Fix direct_url in python PEP660 editable wheels (again) #20798
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We were using the first entry in
source_roots_result.path_to_root
to populate the editable wheel'sdirect_url
. However, that does not work as I expected it to becauseSourceRootsRequest.dirs
andSourceRootsResult.path_to_root
both get sorted as soon as the dataclass is created (if not before).PR #20486 was my first attempt at fixing this, but that wasn't enough. Since the heuristics used before #20486 and in #20486 were both inaccurate due to dataclasses getting sorted, this abandons the heuristics altogether, explicitly requesting the source root for the
python_distribution
target.This time, I added a test to make sure direct_url.json has the contents we expect.
Note: This is ultimately a cosmetic bug. The direct_url gets printed in the output of
pip list
, but is otherwise not really exposed anywhere. So, it's odd when it's the wrong directory, but does not break any functionality.