Implement PEP 660 allowing both "strict" and "lax/loose" approaches#3265
Conversation
FAQ about the implementation:Why is the implementation much more complex than the previous PoCsThis implementation tries to handle the implicit requirement that came up in the previous discussions: allow the user to chose which trade-off makes more sense for the use case in hands. Naturally, supporting multiple strategies instead of only one increases code size/complexity Why
|
Downsides/short-comings of the proposed implementation
|
891711f to
e2135d5
Compare
|
Updates:
|
|
Hi Anderson. Thanks for all the hard work on this effort. I'm really excited to see the progress. Thanks also for providing an overview of the approach and its downsides. I haven't reviewed the implementation specifically, but based on the description you've provided, it sounds like you've found a fairly robust solution. If you're even moderately happy with it, I'm happy to move forward with it. |
|
Thank you very much Jason. I will wait a few days to see if Paul has any objection, otherwise I will go ahead and follow a very similar process that I did for PEP 621 and ask for feedback from the community (maybe using a beta version?). |
|
Ok, my plans moving forward:
Footnotes
|
50c1d09 to
d931716
Compare
Changes: - Deprecate the --egg-base parameter for dist_info and add --output-dir as replacement (Since the egg format is mostly deprecated, it is nice to move away from this nomenclature...)
- Add implementation of editable strategy based on a link tree
- This is the `strict` implementation.
- Only files are linked, not directories.
- This approach makes it possible to use harlinks when softlinks are not
available (e.g. Windows)
- It also guarantees files that would not be part of the final wheel are
not available in the editable install.
- Add non-editable files to the produced wheel wheel (e.g. `headers`,
`scripts`, `data`)
According to the PEP 420, namespace packages need to gracefully handle
later additions to path.
- Use a `PathEntryFinder` + an arbitrary placeholder entry on `sys.path`
to force `PathFinder` to create a namespace spec.
- Since `_NamespacePath` and `_NamespaceLoader` are private classes (or
just documented for comparison purposes), there is no other way to
implement this behaviour directly [^1].
[^1]: Reimplementing _NamespacePath + a custom logic to maintain
namespace portions don't have a corresponding path entry also
seems to have the same end result.
d931716 to
daaf3ab
Compare
|
Any idea when this will make it into a release? |
It will hopefully soon. This was the initial proof of concept to see if the other maintainers agree with the approach. I am refining the implementation now to make it more appropriate for a release. Then the plan is to open for the community to test and then an actual release. |
|
@theo-brown, please feel free to participate of the preliminary round of tests :) |
| 'prepare_metadata_for_build_wheel', | ||
| 'build_wheel', | ||
| 'build_sdist', | ||
| 'get_requires_for_build_editable', |
There was a problem hiding this comment.
@abravalheri You forgot to add 'prepare_metadata_for_build_editable' to the __all__ list.
This PR is an attempt to implement editable installs (PEP 660) in such a way that it allows for both “strict” and “loose/lax” editable installations. The overall approach, and the rationale behind which “editable mode” is picked by default is discussed in https://discuss.python.org/t/pep-660-and-setuptools/14855/2.
Summary of changes
bdist_wheeland avoid re-implementingwheellogicnamespace_packageshandling (based on the existingdevelopcommand).pthfilessrc-layout..pthfiles.MetaPathFinderand offers the following improvements over the existing implementation (developcommand):package_dirmappingssys.path(As always) this task ended up being tricker than I was expecting, so I also divided this PR in a series of smaller PRs that can be reviewed independently (but only if the reviews think that reviweing separated PRs can help). Let me know if there is anything different I could do to facilitate the review.
Note, however, that this division was an afterthought, so between “sub-PRs” there might be transient code/changes that are not part of the end result.
dist_infoto use--output-dirinstead of--egg-baseabravalheri/setuptools#9bdist_wheelabravalheri/setuptools#3namespace_packagesineditable_wheelabravalheri/setuptools#4.pthfile abravalheri/setuptools#5MetaPathFinderfor top-level packages abravalheri/setuptools#7Side note
For the sake of not increasing even more the size of the change, I am currently not providing any news fragment or docs for the implementation. Depending on how the feedback/review go, I would provide that in a later stage.
Work towards #2816.
Pull Request Checklist
changelog.d/.(See documentation for details)