Pip fetches from files.pythonhosted.org despite local mirror was specified

Hi, thanks a lot for the fast reply. Unfortunately, I can’t provide a publicly available index, as it is firewalled for local university use only. Fortunately, we were able to fix it internally.

Our pip mirror is a local nginx instance with URL rewriting enabled. Apparently since PoC of PEP 691 · pypa/pip@6f167b5 · GitHub, pip requests the mirror list with a different MIME type. However, nginx per default only applies URL rewriting to text/html content. This made it difficult to debug, as the responses looked perfectly fine when fetched via curl, but apparently didn’t work when fetched with pip. Adding sub_filter_types ‘*’; enables URL rewriting for all MIME types, and therefore fixed the issue. From the nginx manual:

Syntax: sub_filter_types mime-type …;
Default:

sub_filter_types text/html;

Context: http, server, location

Enables string replacement in responses with the specified MIME types in addition to “text/html”. The special value “*” matches any MIME type (0.8.29).

Additionally, the caching mechanisms of pip made it harder as we initially didn’t notice that the issue was already fixed. So if you have similar problems, try cleaning your cache with pip cache remove *.

Still, thanks a lot for the fast response :slight_smile: Maybe this helps other people with a similar issue in the future.

1 Like