Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micropip.freeze fails when a pypi package would clobber a bundled pyodide package #171

Closed
bollwyvl opened this issue Jan 3, 2025 · 1 comment · Fixed by #172
Closed

Comments

@bollwyvl
Copy link
Contributor

bollwyvl commented Jan 3, 2025

With micropip 0.8, overloading a package as shipped in the pyodide distribution's pyodide-lock.json with an explicit wheel from e.g. PyPI fails:

# on https://pyodide.org/en/0.27.0/console.html
import micropip
>>> await micropip.install(["https://files.pythonhosted.org/packages/2d/14/d1bf3b7141ad5a42c26e4173a69e3e6529bd92b05bc587c570d28b6a3ce8/pyodide_http-0.2.1-py3-none-any.whl"])
>>> micropip.freeze()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/lib/python3.12/site-packages/micropip/package_manager.py", line 175, in freeze
    return freeze_lockfile(self.repodata_packages, self.repodata_info)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/freeze.py", line 16, in freeze_lockfile
    return json.dumps(freeze_data(lockfile_packages, lockfile_info))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/micropip/freeze.py", line 27, in freeze_data
    packages = dict(sorted(package_items))
                    ^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'dict' and 'dict'

This is likely because:

sorted([("pyodide-http", {}), ("pyodide-http": {})])

... leads to a comparison of the second member of the tuples as a tiebreaker.

@bollwyvl
Copy link
Contributor Author

bollwyvl commented Jan 3, 2025

Here is a strawman PR which removes the itertools import, and just accepts that merging and sorting two dict instances is hard with iterators.

#172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant