bytecodealliance / componentize-py

Apache License 2.0
147 stars 16 forks source link

add support for targeting multiple worlds with a single component #76

Closed dicej closed 7 months ago

dicej commented 7 months ago

A while back, I added support for componentize-py.toml files in Python packages, which allows developers to embed WIT files in their Python packages and also specify where the bindings should be generated with respect to the Python module hierarchy. This is useful when publishing SDK packages for a WIT world, which may include additional, handwritten code on top of the generated bindings. However, it wasn't possible to use more than one such package at a time, nor was it possible to use such a package and also target an additional, application-level WIT world beyond those defined in the package.

This commit removes those instructions, allowing the user to specify multiple worlds (up to one per package, plus one additional, application-level world) when generating a component. Since those worlds might overlap, we merge them together using wit_parser::Resolve::merge and then generate bindings for each world such that the bindings for a given world may alias bindings generated for an earlier world.

This required quite a bit of refactoring, and the code responsible for juggling all the WIT directories, worlds, and bindings is a bit awkward since it's trying to handle a wide range of use cases. It also needs more (automated) testing. In short, it's not fully baked yet, but I want to get a pre-release out so folks can try it while I clean things up.