-
Notifications
You must be signed in to change notification settings - Fork 231
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
chore: Add a PlatformModule type #1461
Conversation
5b33087
to
e9333a7
Compare
Could someone merge this? |
This avoids the repetition of the platform checks in __main__.py by defining a dataclass with `get_python_configurations` and `build`.
e9333a7
to
26dd3f3
Compare
I've just been playing with this and I think it would be simpler to use the module itself as the 'interface' object. We can type it with a Protocol I believe, like so class PlatformModule(typing.Protocol):
# note that as per PEP544, the self argument is ignored when the protocol
# is applied to a module
def get_python_configurations(self, build_selector: BuildSelector, architectures: Set[Architecture]) -> typing.Sequence[GenericPythonConfiguration]:
...
def build(self, options: Options, tmp_path: Path) -> None:
... |
I have a version that looks to be working locally, I can push here if you like? |
I'm off to bed so I've pushed that, hope that's okay. I think it's a bit simpler without the extra object. |
|
||
def get_platform_module(platform: PlatformName) -> PlatformModule: | ||
if platform == "linux": | ||
return cibuildwheel.linux |
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.
Nice! I did not realize you could do this.
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.
When I tried, I left out the self parameter and got complaints.
This avoids the repetition of the platform checks in main.py by defining a dataclass with
get_python_configurations
andbuild
.