Finalize distribution options various data #2034
Closed
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.
The problem
Various modules using finalize_distribution_options hook do some work themselves:
pyproject.toml
. Finding it poses issues, so they usually consider cwd as a "root dir", as this solution the easiest to implement , which IMHO is not very correct, sincepython3 ../setup.py bdist_wheel
for example won't work, which is critical to some packages that bootstrap ourselves, so IMHOsetup.py
should work no matter in which dir a user is. I have implemented the solution for searchingsetup.py
usinginspect
, but I cannot expect other people to implement it.pyproject.toml
.Summary of changes
I have implemented computing this info as a part of setuptools in #2032.
In this PR the following mechanism is implemented.
1 A dev adds parameters with certain names into a hook func signature. I can make it simpler by just providing a single
FinalizeDistributionOptionsHookArgsCache
object (this has benefits that entry point internals can trigger lazy evaluation based on code path within the entry point), but it would break backward compatibility. Another alternative is to put the requested info into the JSON metadata introduced in #2033, so we can even isolate the hooks into separate processes.2. Setuptools inspects the signature and computes the params it should provide. If there is only 1 param with an unknown name it emits a warning about the legacy behavior and passes
dist
as an only parameter. #2037 fixes setuptools own entry points to match the convention, also it marks them as static methods that they indeed are.3. when calling the function, setuptools provides the computed params.
Closes
Pull Request Checklist