Skip to content

[Plugin] Dynamic Plugin API #105

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

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft

[Plugin] Dynamic Plugin API #105

wants to merge 5 commits into from

Conversation

DEKHTIARJonathan
Copy link
Member

@DEKHTIARJonathan DEKHTIARJonathan commented Jun 18, 2025

Caution

If you want to check this out, I advise using this branch: https://github.com/wheelnext/pep_xxx_wheel_variants/tree/interactive_plugins

Note

This PR is in draft, because I need to fix the unittests. However I tested the most basic use case and it seems to work reasonably well :)

This PR removes a significant portion of #99 in favor of a more flexible less "maintenance intensive" approach while allowing maximum freedom in plugin logic & sorting.

This PR introduces the concept of PluginDynamicType. The older PluginType becomes PluginStaticType (fully backward compatible).

  • PluginDynamicType => takes the VariantProperties of the "candidate variants" in inputs

    • They can use custom data types:
      • float
      • SemVer
      • CalVer
    • Any sorting logic they see fit to determine why A :: B :: C > A :: B :: D.
  • PluginStaticType => take no input and rely on pure string matching to operate

While PluginDynamicType is significantly more powerful, its implementation is significantly more delicate. And we should recommend plugin authors to use PluginStaticType interface as often as possible and rely only use PluginDynamicType when absolutely necessary.

Not only this PR enables to grasp fully the vast diversity of the variant ecosystem:

  • float/int comparison (e.g. minimum RAM requirement)
  • Version Schema (e.g. SemVer, CalVer, ARMVer ??)
  • etc.

It does it in a significantly more flexible, less arbitrary, more cleanly and more efficiently than PR #99.
The latter statement can be appreciated with the "fairly reduced scope" of the PR compared to #99.

@DEKHTIARJonathan DEKHTIARJonathan requested a review from mgorny June 18, 2025 23:36
@DEKHTIARJonathan DEKHTIARJonathan marked this pull request as draft June 18, 2025 23:37
@DEKHTIARJonathan
Copy link
Member Author

@mgorny if you check out https://github.com/wheelnext/pep_xxx_wheel_variants/tree/interactive_plugins - you can test completely the concept with dummy-project and sandbox-project in mockhouse.

I still need to fix some unittests. I'll do that later :)

@@ -46,19 +57,30 @@ def load_plugins(plugin_apis: list[str]) -> Generator[PluginType]:
else:
plugin_instance = plugin_callable

required_attributes = PluginType.__abstractmethods__
if isinstance(plugin_instance, PluginStaticType):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance() won't work here since the protocol allows optional methods (get_build_setup). Also, I'm not sure if it's going to work with ModuleType and so on.

"--plugin-api",
action="append",
help="Load specified plugin API",
required=True,
)

parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass them via JSON. Then you won't need most of the boilerplate.

@classmethod
def from_str(cls, input_str: str) -> Self:
# Try matching the input string with the regex pattern
match = VALIDATION_PROPERTY_REGEX.fullmatch(input_str.strip())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of subprocess is to keep validation in the parent, and pass only validated data.

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