-
-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix direct_url in python PEP660 editable wheels #20486
Conversation
We were using the first entry in `build_time_source_roots` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `build_time_source_roots` gets sorted before creating the `DistBuildRequest`, so the first entry is not actually the `source_root` of the `python_distribution` target. To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel.
We were using the first entry in `build_time_source_roots` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `build_time_source_roots` gets sorted before creating the `DistBuildRequest`, so the first entry is not actually the `source_root` of the `python_distribution` target. To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel. Functionally, the editable wheels get installed just fine. However, the output of `pip list` in an exported venv might show the wrong path if there happens to be a source_root that sorted before the source_root of the distribution. Importing the python code still works, however, as all of the source_roots are included in the `.pth` file. Thus, this is a cosmetic / correctness bug.
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ✔️ 2.19.xSuccessfully opened #20494. Thanks again for your contributions! |
… (#20494) We were using the first entry in `build_time_source_roots` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `build_time_source_roots` gets sorted before creating the `DistBuildRequest`, so the first entry is not actually the `source_root` of the `python_distribution` target. To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel. Functionally, the editable wheels get installed just fine. However, the output of `pip list` in an exported venv might show the wrong path if there happens to be a source_root that sorted before the source_root of the distribution. Importing the python code still works, however, as all of the source_roots are included in the `.pth` file. Thus, this is a cosmetic / correctness bug. Co-authored-by: Jacob Floyd <[email protected]>
We were using the first entry in `build_time_source_roots` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `build_time_source_roots` gets sorted before creating the `DistBuildRequest`, so the first entry is not actually the `source_root` of the `python_distribution` target. To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel. Functionally, the editable wheels get installed just fine. However, the output of `pip list` in an exported venv might show the wrong path if there happens to be a source_root that sorted before the source_root of the distribution. Importing the python code still works, however, as all of the source_roots are included in the `.pth` file. Thus, this is a cosmetic / correctness bug.
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ✔️ 2.18.xSuccessfully opened #20602. ❌ 2.19.xI was unable to cherry-pick this PR to 2.19.x, likely due to merge-conflicts. Steps to Cherry-Pick locallyTo resolve:
Please note that I cannot re-run CI if a job fails. Please work with your PR approver(s) to re-run CI if necessary. ❌ 2.20.xI was unable to cherry-pick this PR to 2.20.x, likely due to merge-conflicts. Steps to Cherry-Pick locallyTo resolve:
Please note that I cannot re-run CI if a job fails. Please work with your PR approver(s) to re-run CI if necessary. When you're done manually cherry-picking, please remove the Thanks again for your contributions! |
… (#20602) We were using the first entry in `build_time_source_roots` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `build_time_source_roots` gets sorted before creating the `DistBuildRequest`, so the first entry is not actually the `source_root` of the `python_distribution` target. To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel. Functionally, the editable wheels get installed just fine. However, the output of `pip list` in an exported venv might show the wrong path if there happens to be a source_root that sorted before the source_root of the distribution. Importing the python code still works, however, as all of the source_roots are included in the `.pth` file. Thus, this is a cosmetic / correctness bug. Co-authored-by: Jacob Floyd <[email protected]>
Dang. This was not a complete fix for this issue. I'll have to push a follow-up PR to finish fixing it. |
We were using the first entry in `source_roots_result.path_to_root` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `SourceRootsRequest.dirs` and `SourceRootsResult.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.
We were using the first entry in `source_roots_result.path_to_root` to populate the editable wheel's `direct_url`. However, that does not work as I expected it to because `SourceRootsRequest.dirs` and `SourceRootsResult.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.
We were using the first entry in
build_time_source_roots
to populate the editable wheel'sdirect_url
. However, that does not work as I expected it to becausebuild_time_source_roots
gets sorted before creating theDistBuildRequest
, so the first entry is not actually thesource_root
of thepython_distribution
target.To fix this, we capture the dist's source_root before the source_roots get sorted and use that when building the PEP660 editable wheel.
Functionally, the editable wheels get installed just fine. However, the output of
pip list
in an exported venv might show the wrong path if there happens to be a source_root that sorted before the source_root of the distribution. Importing the python code still works, however, as all of the source_roots are included in the.pth
file. Thus, this is a cosmetic / correctness bug.This is the relevant section of the
pip list
output for the StackStorm project so you can see how odd it looks to have the wrong path showing: