pyodide / micropip

A lightweight Python package installer for Pyodide
https://micropip.pyodide.org
Mozilla Public License 2.0
76 stars 21 forks source link

Port `freeze` into PackageManager #115

Closed RulerOfCakes closed 3 months ago

RulerOfCakes commented 3 months ago

After #114, I'm continuing to implement each command into PackageManager.

As a relatively simple first change freeze() now uses the given state instead of the global variables.

Note that the current implementation of freeze still reads from importlib.metadata.distributions(), so it isn't completely independent from the global environment. This isn't as trivially separable as the repodata_* variables due to certain intrinsic quirks as discussed in the previous PR, so for now I'm leaving the path/site-packages/install related elements as-is.

RulerOfCakes commented 3 months ago

After the discussion about potentially having separate install directories in the previous PR, I've taken a look at tox and from a quick overview it looks like their approach is to create an entirely separate python environment with virtualenv and avoid juggling with path / site-packages in the same environment. I'm unsure how to potentially incorporate this approach into micropip to work with pyodide as it doesn't seem to be an easy task, imo it feels like it would be better to leave it as a TODO for now. Any thoughts? cc: @ryanking13

ryanking13 commented 3 months ago

Note that the current implementation of freeze still reads from importlib.metadata.distributions(), so it isn't completely independent from the global environment. This isn't as trivially separable as the repodata_* variables due to certain intrinsic quirks as discussed in the https://github.com/pyodide/micropip/pull/114#discussion_r1648020731, so for now I'm leaving the path/site-packages/install related elements as-is.

imo it feels like it would be better to leave it as a TODO for now. Any thoughts?

Yes, this can be quite complicated, and I am not even sure it makes sense for Pyodide. so I think we can work on it separately later, for now you don't need to worry about making the PackageManager work independently.

hoodmane commented 3 months ago

Thanks @RulerOfCakes!