-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
micropip is used in many different downstream projects and has many different requirements, so I think it would be nice to 1) modularize overall micropip behavior, and 2) use dependency injection to customize micropip behavior.
micropip.Micropip()
Currently, micropip only has a global state and can only be used with global APIs like micropip.install and micropip.freeze.
This issue proposes to define a Micropip class in addition to this, and make it possible to create instances with local state.
The existing APIs will still be available (no breaking changes), and they will internally reference the default Micropip instance.
await micropip.install("...") # this will still work
# Additionally, we have this.
micropip1 = micropip.Micropip(param1, param2, ...)
await micropip1.install()Dependency injection
When instantiating the Micropip instance, we can accept several parameters including, resolver, installer, etc.
def Micropip:
def __init__(self, resolver, installer, etc):
self.resolver = resolver
self.installer = installer
def dependency_resoltion(self, package):
self.resolver.do_dependency_resolution(package)
def install_package(self, package):
self.installer.do_install_package(package)This will make it easier to tweak micropip's behavior, which will make it easier for us to implement new features, or people can implement their own features. For instance, someone can make a backtracking resolver and replace our simple resolver if they want, or it might be even possible to use micropip in non-Pyodide environments.
Required works
The global state of micropips, which is currently jumbled in many ways, needs to be better categorized by purpose and defined in a clear API.