-
-
Notifications
You must be signed in to change notification settings - Fork 598
wheel: support for 'plugin' type entry_points #349
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
Conversation
@@ -157,12 +158,26 @@ def add_metadata(self, extra_headers, description, classifiers, requires, | ||
metadata += "\n" | ||
self.add_string(self.distinfo_path('METADATA'), metadata) | ||
|
||
def add_entry_points(self, console_scripts): | ||
def add_entry_points(self, console_scripts, plugins): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change it so that the .bzl file just merges console_scripts and plugins, and wheelmaker just always sees only entry_points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
match = pattern.fullmatch(line) | ||
if not match: | ||
raise ValueError('{line} is not a valid entry point'.format(line=line)) | ||
plugin_type = match.group(1).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can produce multiple groups with the same name. Even if that's allowed by the spec (I'm not sure?) it would be better to order the entries so that each group appears only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not happen before (at least from wheel.bzl
) because there was only one entry allowed per group. As part of switching that to allow multiple entry points per group, rewrite this code from scratch. I believe all such concerns are now handled.
* deprecate console_scripts, update docs * rename plugins to entry_points, update docs * switch to string_list_dict to support multiple entries per group * sorting of groups and entries within groups for idempotence
This reverts commit 5d5a06d.
@@ -157,12 +158,26 @@ def add_metadata(self, extra_headers, description, classifiers, requires, | ||
metadata += "\n" | ||
self.add_string(self.distinfo_path('METADATA'), metadata) | ||
|
||
def add_entry_points(self, console_scripts): | ||
def add_entry_points(self, console_scripts, plugins): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
match = pattern.fullmatch(line) | ||
if not match: | ||
raise ValueError('{line} is not a valid entry point'.format(line=line)) | ||
plugin_type = match.group(1).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not happen before (at least from wheel.bzl
) because there was only one entry allowed per group. As part of switching that to allow multiple entry points per group, rewrite this code from scratch. I believe all such concerns are now handled.
name = match.group(2).strip() | ||
object_reference = match.group(3).strip() | ||
if name in group_dict: | ||
raise ValueError("Duplicate entry for name {name} in group {group}".format(name=name, group=group)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a stock formatter for this repo? I tried yapf
but it changed way more than just the modified code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andyscott @thundergolfer : This change looks good to me (except for the comments I've left). Should I merge it?
I authored the initial implementation of py_wheel for this repo and kept maintianing it, but with you as new maintainers I'd like a clarification if I should continue merging changes here or would you prefer to review/merge all new PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presubmit complains about the print() function.
Let's remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
PR Checklist
.par
files. See CONTRIBUTING.md for infoPR Type
What kind of change does this PR introduce?
What is the current behavior?
Python wheels have a rich concept called
entry_points
. The most common use of these is the existingconsole_scripts
support: command-line wrappers for Python code.However, there are many more uses. Another common one is
plugins
-- the Python version of, say, Java@AutoService
. This is howpytest
finds modules on thePYTHONPATH
.This PR is something we've been using for a while to add our own plugins to the
entry_points
file; but the change is worth discussing.In one sense, this is stupid. There's some interference between
console_scripts
andplugins
-- in reality, the underlying structure is:So maybe this would be best as a single argument merging
console_scripts
in:{group: {k1: v1, k2: v2, ...}, ...}
... if we wanted to make a breaking change.But since
console_scripts
already existed, I addedplugins
separately. (I did not call itentry_points
since it doesn't handleconsole_scripts
).(There are of course, other backwards-compat options like adding an
entry_points
arg that throws ifconsole_scripts
is present.)Issue Number: not yet, but happy to file one if needed
What is the new behavior?
Wheels built by
rules_python
supportentry_points
other thanconsole_scripts
, hopefully without breaking existingconsole_scripts
support.Does this PR introduce a breaking change?
Other information
See https://packaging.python.org/specifications/entry-points/ and specifically https://packaging.python.org/guides/creating-and-discovering-plugins/#using-package-metadata
Sorry for not ticking all the boxes from jump - this has been sitting around a while and when I realized PRs are being reviewed again I thought it might be worth starting the discussion.
This change is