pyodide / micropip

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

Fix micropip.install to search shared libraries inside the wheel correctly #97

Closed ryanking13 closed 5 months ago

ryanking13 commented 5 months ago

Previously, micropip was not able to locate shared libraries in the .libs directory of the wheel.

For instance, in Pyodide 0.25.0,

await pyodide.loadPackage("Shapely")

works, while

>>> import micropip
>>> await micropip.install("https://cdn.jsdelivr.net/pyodide/v0.25.0/full/Shapely-1.8.
2-cp311-cp311-emscripten_3_1_46_wasm32.whl")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/lib/python3.11/site-packages/micropip/_commands/install.py", line 176, in ins
tall
    await asyncio.gather(*wheel_promises)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 168, in install
    await self.load_libraries(target)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 159, in load_libr
aries
    await asyncio.gather(*map(lambda dynlib: loadDynlib(dynlib, False), dynlibs))
pyodide.ffi.JsException: Error: Didn't expect to load any more file_packager files!

does not work.

This is because micropip.install does not search the path that pyodide.loadPackage looks for.

This PR fixes it by using the same API pyodide.loadPackage is using when loading shared libraries.

ryanking13 commented 5 months ago

Oh, I forgot to update the changelog...