Skip to content

Use dependency injection technique to manage compatibility layer #237

Open
@ryanking13

Description

@ryanking13

Original comment: #213 (comment)

Micropip has a compatibility layer, which defines a few functions or attributes that come from the Pyodide runtime.

In prod environment, the compat layer is imported from Pyodide, and for unit testing, the dummy compat layer is used (code pointer)

For now, this compat layer is imported everywhere in micropip, but now we have a global singleton class for micropip (#141), I would like to make this compat layer a dependency of this class, using the dependency injection technique.

By doing this, we can

  1. Remove _compat_not_in_pyodide.py from the production environment. ysing it only in unittest.
  2. Users can modify the compatibility layer if needed. For example, if someone want to replace fetch with their custom method (downloading package from cache, indexDB, etc), it is possible by replacing the fetch method in compat layer.

I already made a few PRs to remove the importing compat layer globally, will continue working on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions