micropip icon indicating copy to clipboard operation
micropip copied to clipboard

micropip.install(["pkg==2", "pkg"]) always brings in "pkg"

Open WebReflection opened this issue 8 months ago • 0 comments

Coming from https://github.com/pyodide/pyodide/issues/5603#issuecomment-2824535062 and, as suggested by @hoodmane, here the issue:

  • when an explicit version of a package is specified in the list, if the same package without version, or any other package that depends on pkg is present, the default version specified in the yaml file becomes the import pkg
  • when it comes to multiple packages at once, there is no solution to this, example: micropip.install("fsspec ==2025.3.2", "fastparquet") where fastparquet has fsspec as dependency, both current 2024.3.1 and 2025.3.2 are downloaded but importing fsspec will always provide the indirectly resolved package instead of the explicitly required 2025.3.2
  • if packages are loaded in different steps, everything works as expected
# this always brings in both but fsspec will be 2024.3.1
micropip.install(["fsspec ==2025.3.2", "fsspec"])
# fsspec 2024.3.1

# doing this will download `fsspec` once with the desired version
micropip.install("fsspec ==2025.3.2")
micropip.install("fsspec") # no-op
# fsspec 2025.3.2

The same goes for mixed packages:

micropip.install(["fsspec ==2025.3.2", "fastparquet"])
# fsspec 2024.3.1 imported by parquet as dependency

# this works as expected
micropip.install("fsspec ==2025.3.2")
micropip,install("fastparquet")
# fsspec 2025.3.2 and not re-imported via fastparquet

Thanks in advance for looking into this!

WebReflection avatar Apr 23 '25 15:04 WebReflection