xeus icon indicating copy to clipboard operation
xeus copied to clipboard

Add ability to patch modules

Open martinRenou opened this issue 3 months ago • 4 comments

Problem

Some packages cannot be installed in an emscripten-wasm32 because of underlying dependencies that cannot be installed.

For some of them, we should provide mock packages published on emscripten-forge. But it would make sense to add the ability for the user to mock packages themselves.

Proposed Solution

  • for the pre-built env, we can dynamically create a mock-channel containing wanted packages so that micromamba does not complain during the environment solving. This means adding a new option in the addon.
  • for dynamically installed packages using mambajs, we can tell mambajs the mocked package is installed and it should not complain upon resolve

Additional context

Pyodide does this https://micropip.pyodide.org/en/latest/project/api.html#micropip.add_mock_package but it's Python specific. Let's not make a Python specific solution here

martinRenou avatar Nov 13 '25 08:11 martinRenou

cc. @trungleduc

martinRenou avatar Nov 13 '25 08:11 martinRenou

@martinRenou maybe a --ignore-missing-like flag in mamba/mambajs would solve the same problems.

DerThorsten avatar Nov 13 '25 09:11 DerThorsten

I've been thinking about that as well 👍🏽 I haven't seen some flag like this in micromamba. And it seems conda folks would disagree to implement such feature https://github.com/conda/conda/issues/5374

I'd have mixed feelings about such a feature as well, it makes the environment actually broken and not correctly resolved.

The ability to mock packages also allows people to put actual logic in the package, so that e.g. Python imports do work.

martinRenou avatar Nov 13 '25 09:11 martinRenou

Thanks @martinRenou, for opening it, I have a use case where I want to install shiny in xeus-python, then got the following error

error    libmamba Could not solve for environment specs
    The following packages are incompatible
    └─ shiny =* * is not installable because there are no viable options
       ├─ shiny [0.10.1|0.2.3|...|0.9.0] would require
       │  └─ websockets >=10.0 *, which does not exist (perhaps a missing channel);
       └─ shiny [0.10.2|1.0.0|...|1.4.0] would require
          └─ watchfiles >=0.18.0 *, which does not exist (perhaps a missing channel).

Shiny would work fine without these libs, but I can't create the environment. If xeus-python could support something like this:

....
dependencies:
  - xeus-python
  - shiny
mock:
  - websockets 
  - watchfiles 

then it would be great!

The ability to mock packages also allows people to put actual logic in the package, so that e.g. Python imports do work.

This is even better 💯

trungleduc avatar Nov 13 '25 22:11 trungleduc