pdm_configure hook method - #310
Draft
sneakers-the-rat wants to merge 2 commits into
Draft
Conversation
✅ Deploy Preview for pdm-backend-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
See #309 |
Contributor
Author
|
Oh cool! Thanks. That seems like it will probably meet my need in the original issue. If this PR would be something you'd be interested in as well, I can finish it by adding docs for it, otherwise feel free to close. I can see it being independently useful for anyone who wants to do something else with the config before it's validated, but also wouldn't be offended if you decide it's not useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix: pdm-project/pdm#3824
This problem has blocked me so i had some time to work on it:
There is a problem with the packaging spec such that it is ambiguous what to do with a
'../../README.md'outside of the path of the package root. this is common in monorepos. However../../relative path breaks builds, as the tarfile library refuses to unpack files outside of the directoryreadme="README.md"and then copying from the repo root is impossible, because theConfigobject fails validation since the readme file doesn't exist.however, rather than making some unspec'd behavior a part of the builder, @frostming suggested that a configuration hook might be an acceptable fix to the problem. This is a more generally useful change, as currently all the hooks run after the configuration has been validated. If there is any customization that needs to happen that relates to the configuration, i.e. avoiding the above configuration error, copying a file so the configuration is valid, then it can use this hook. This effectively makes any field dynamic if people want it to be.
Other parts of the builder need the
config(including getting the hooks itself), so I couldn't just have a hook that happens entirely before the configuration is loaded. That would also make it impossible to mutate the config, which sort of defeats the purpose of the hook. So I split the validation phase of theConfigobject out of its__init__method, and it is called after the hook is called.I just wanted to open this as a draft at first to see if it would be acceptable, and if it is I can also update the docs to match. I didn't see other hooks having specific behavioral tests so I didn't add them, but if we want to have a test that the hook can mutate and correct an invalid
pyproject.tomlconfig, just let me know.happy to make any changes!