pyodide / micropip

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

ENH Add micropip.uninstall() #55

Closed ryanking13 closed 1 year ago

ryanking13 commented 1 year ago

Related: #51

Add micropip.uninstall() method, which uninstalls packages that are installed.

I used a quite simple approach for this compared to pip uninstall, since we only support installing wheels, and wheel metadata contain a list of files in the archive, so I just iterated through the list and removed them.

I didn't add a rollback feature if uninstall fails in this PR. I'm not sure it is worth it, but probably we can add it as a follow up.

ryanking13 commented 1 year ago

What would happen if we uninstall a package installed via loadPackage? If it also uninstalls it, we need to be sure loadPackage would be aware of it.

I think removing keys in loadedPackages does the job. Will add a test.

ryanking13 commented 1 year ago

@rth Thanks for the review! I think I addressed all of your comments.

I changed the code a bit after your review (simplified how files are retrieved, and added tests), so I would appreciate it if you can review this one more time.