-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add 'setuptools.sub_command' entry-points #2899
base: main
Are you sure you want to change the base?
Conversation
disclaimer: the following feedback is made without any in-depth analysis of the problem or solution.
When I see
As a nitpick, let's use |
Hi @jaraco thank you very much for the comments and sorry for the long time it took me to reply.
Do you mean having 2 parameters? One for the priority order (i.e. the order with which the plugins will be loaded) + one for the position? I think that even if we add such kind of parameter there will always be the chance that the position in the ordered set is not consistent across multiple environments. Depending on which dependencies the final user adds to their Would it be better if instead
I agree with you in this point, however |
Alternatively we can give up on adding another type of entry-point and recommend for users to implement the plugins using a combination of This approach seems to be viable nowadays (see https://github.com/abravalheri/experiment-setuptools-plugin). |
I feel like it isn't possible to guarantee any consistent complete ordering when considering multiple plugins that don't know about each other.
|
a85759c
to
93ce5a0
Compare
In the keyring project, the plugins specify a priority (with some coded heuristics about the meaning) and some of them use the priority of another to specify a relative priority. That approach has its downsides, but it does provide a straightforward way to order the plugins. I don't feel strongly about it. Happy to proceed with whatever approach Anderson prefers. |
As described in pypa#2591, users might wish to add custom steps to the build process, and this can be done via sub-commands. The changes implemented here expose a new set of entry-points to facilitate this process. This allows the implementation of custom steps in 3rd-party plugins.
ae5e1f0
to
6de7f73
Compare
Hi @jaraco, after giving some thought to this problem, I decided to modify the PR in the following ways:
Please feel free to bike-shed this names, I am not very sure myself. |
This PR expands on the work done in #2591, to support plugins that wish to add custom steps to the build process.
Summary of changes
The method
setuptools.Command.get_sub_commands
is extended to load sub-commands fromsetuptools.sub_commands.*
entry-points. (It also automatically insert items todistribution.cmdclass
, so there is no need to specify extradistutils.commands
entry points).The entry-points should correspond to a
setuptools.Command
subclass when loaded.There are 3 optional attributes these subclasses can define to customise when/if the sub-commands will run:
after
ORbefore
-- a string with the name of another already defined sub-command (by default the new sub-command will run after the last of the existing ones).condition
-- a string with the name of a predicate method in the parent command class.Closes (potentially?) #2591
Things purposefully not considered (future work)
The changes in this PR improve the ergonomics for setuptools plugins writers, but not for end-users (via
setup.py
orsetup.cfg
files).Currently there is an asymmetry on how plugin writers and end-users can customize the setuptools build process. Plugin writers can define any entry-point, while end users are restricted to
cmdclass
.I believe that this asymmetry should be considered in a separated proposal, and then, the ergonomics defined here can be extended to end-users.
Pull Request Checklist
changelog.d/
.(See documentation for details)