Force pip to use json api instead of html api when connecting to an index (original) (raw)
I was using GitHub - ido50/morgan: PyPI Mirror for Restricted/Offline Environments to mirror some packages from pypi in a bastion server and then transport them to an airgapped environment.
I noticed that pip always uses the Accept: application/vnd.pypi.simple.v1+json
header when connecting to pypi, while it always uses application/vnd.pypi.simple.v1+html
when connecting to my morgan host. Is it hard coded or is there a way to tell pip which api to use?
Here’s a piece of the pip install typing-extensions -vvv
output without specifying an index:
Fetched page https://pypi.org/simple/typing-extensions/ as application/vnd.pypi.simple.v1+json
VS using a local index:
Fetched page https://morgan.local/pypi/typing-extensions/ as application/vnd.pypi.simple.v1+html
The typing-extensions
package have an inconsistent name between the URL and the metadata. While other packages typically depend on the dashed typing-extensions
, the tarball and metadata use the underscored typing_extensions
.
These inconsistencies have led to an error when using my local index.
ERROR: Requested typing-extensions>=3.6.4; python_version < "3.8" from https://morgan.local/pypi/typing-extensions/typing_extensions-4.7.1-py3-none-any.whl#sha256=440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36 (from importlib-metadata>=0.12; python_version < "3.8"->pytest==6.1.1->-r requirements.txt (line 25)) has inconsistent Name: expected 'typing-extensions', but metadata has 'typing_extensions'
Utilizing pypi operates without issues. This suggests that the problem may stem from pip not retrieving the .metadata
file when using the JSON API, thus removing the possibility of comparing name consistency. In contrast, the HTML API prompts pip to download the metadata for such a comparison.
My environment:
- python v3.7.17 (docker.io/library/python:3.7.17, using podman)
- pip v23.0.1
- morgan v0.13.4, forked to include the
requires-python
specification which was not implemented yet
Here’s my questions:
- How to force pip to use the json api to validate my suspicion?
- How an index tells pip which api to use?
- How to tell pip to ignore the naming inconsistencies?
sinoroc (sinoroc) August 9, 2024, 9:28pm 2
This is a bit old. In principle the only version of pip that is supported is the latest version. Have you tried with the latest version of pip?