simple-repository / simple-repository-server

A tool for running a PEP-503 simple Python package repository, including features such as dist metadata (PEP-658) and JSON API (PEP-691)
MIT License
18 stars 0 forks source link

uv compatibility problems (range request not working) #3

Open bewinsnw opened 1 month ago

bewinsnw commented 1 month ago

If you try proxying to pypi and attempt to install jinja with uv against this server, uv will crash.

This is because the headers streamed from pypi: https://github.com/simple-repository/simple-repository-server/blob/fe353669c64ca77ef9621d377bb728a13e6c33ae/simple_repository_server/routers/simple.py#L151

... include "accept-ranges: bytes", which uv takes as being true and then tries to use to fetch metadata from wheels.

I fixed this in my copy with:

            headers = {k: v for k, v in response_iterator.headers.items() if k.lower() != "accept-ranges"}
            print(headers)
            return StreamingResponse(
                content=response_iterator,
                status_code=response_iterator.status_code,
                headers=headers,
            )

It'd be better if we could pass the ranges in the request to the back end, but it all works. The reason why uv is making these range requests is because it didn't understand the "core-metadata" attribute from PEP-714: I recently asked Charlie to fix this so it should be in the next release https://github.com/astral-sh/uv/issues/3689

pelson commented 4 days ago

I have a potential fix for this, which also addresses #4 (it is the same issue I believe).

I'm just waiting on this to be reviewed, but there is a chance it will be delayed a bit due to holidays.

pelson commented 3 days ago

I think this is fixed with v0.6.0. Would you mind taking a look and reporting back? (it should be possible to get a range if the upstream server supports it)