Skip to content

uv can't install lzma wheel created in Python #13310

@konstin

Description

@konstin

I made a wheel using LZMA compression format with this script. pip can install it, but unfortunately, I’m getting an error from uv saying “stream/file format not recognized.”

make-lzma-wheel.py

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "wheel",
# ]
# ///
from zipfile import ZIP_LZMA

from wheel.wheelfile import WheelFile

with WheelFile("fakepkg-0.0.1-py3-none-any.whl", "w", compression=ZIP_LZMA) as zf:
    zf.writestr("fakepkg/__init__.py", b'print("hello world")')
    zf.writestr(
        "fakepkg-0.0.1.dist-info/METADATA",
        """\
Metadata-Version: 2.4
Name: fakepkg
Version: 0.0.1
Summary: fakepkg
Requires-Python: >=3.8

fakepkg is a fake package for testing purposes.
""",
    )
    zf.writestr(
        "fakepkg-0.0.1.dist-info/WHEEL",
        """\
Wheel-Version: 1.0
Generator: fakepkg
Root-Is-Purelib: false
""".encode(),
    )

print("Created fakepkg-0.0.1-py3-none-any.whl")

pip can install this wheel:

$ uv venv --seed
$ .venv/bin/pip install fakepkg-0.0.1-py3-none-any.whl
Processing ./fakepkg-0.0.1-py3-none-any.whl
Installing collected packages: fakepkg
Successfully installed fakepkg-0.0.1
$ .venv/bin/python -c 'import fakepkg'
hello world

uv add or uv pip install fails:

$ cargo run -- pip install fakepkg-0.0.1-py3-none-any.whl
  × Failed to read `fakepkg @ file:///private/tmp/hello/fakepkg-0.0.1-py3-none-any.whl`
  ├─▶ Failed to read metadata: `/private/tmp/hello/fakepkg-0.0.1-py3-none-any.whl`
  ├─▶ Failed to read from zip file
  ├─▶ an upstream reader returned an error: stream/file format not recognized
  ╰─▶ stream/file format not recognized

$ cargo run -- --version
uv 0.7.2+24 (3218e364a 2025-05-05)

Originally posted by @j178 in #13192

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions