Skip to content
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

Finalize distribution options various data #2034

Conversation

KOLANICH
Copy link
Contributor

@KOLANICH KOLANICH commented Mar 19, 2020

The problem

Various modules using finalize_distribution_options hook do some work themselves:

  • they try to find 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, since python3 ../setup.py bdist_wheel for example won't work, which is critical to some packages that bootstrap ourselves, so IMHO setup.py should work no matter in which dir a user is. I have implemented the solution for searching setup.py using inspect, but I cannot expect other people to implement it.
  • they parse pyproject.toml.
  • they find their section in it
  • if the section is present, they do the work using the info from the section and a "root dir"

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

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details

@KOLANICH KOLANICH force-pushed the finalize_distribution_options_various_data branch from 11385f0 to 305cfec Compare March 19, 2020 11:29
… stuff. When an entry point now fails to be loaded, it doesn't disrupt building process.
…setuptools.finalize_distribution_options hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants