-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Plans for using Simple Repository API #62
Comments
For now, this is blocked by: pypi/warehouse#12214: some stale responses does not contain CORS headers added in pypi/warehouse#13222. |
Thanks a lot for looking into this @ryanking13 !
See also the discussion in pyodide/pyodide#3049 though I haven't really made much progress on it. Aside from determining that warehouse is not suitable for this purpose according to its devs, as it's the code for PyPI and too complex to use for other applications. |
Would it be too much work to support both? I mean this would be great to support other hosting solutions that could use the Simple API even independently from PyPI. For instance, to name a new. |
Do you mean supporting both JSON API and Simple API? I think it is not that hard, but I think most private hosting solutions would use Simple API (except for pypiserver), so I was thinking that it should be okay to support only simple API which is now a standard. |
If that outdated cache issue has a workaround for PyPI sure we can only keep Simple API. But so are we talking about HTML Simple API or Json Simple API? It's pretty horrible to have to parse HTML files to extract links to then parse other HTML files and parse more links. I mean maybe for native installers it doesn't matter, but on a web page every bit of overhead matters when loading the page. |
Right, if the cache issue is not resolved for a long time, we may need to provide a JSON API as a fallback... let me see how hard it would be to support both APIs.
Both. I found that there already exists a good parser (https://github.com/brettcannon/mousebender) that can parse both HTML and JSON API. We can add a |
It seems like PyPI JSON-based Simple API (PEP 691) now contains CORS headers correctly, while HTML-based Simple API (PEP 503) still doesn't. Probably PyPI purged all cached JSON responses recently due to PEP 658. test script: import requests
import time
import random
top_pypi_packages = "https://hugovk.github.io/top-pypi-packages/top-pypi-packages-30-days.min.json"
packages = requests.get(top_pypi_packages).json()
rows = packages["rows"]
for idx, package in enumerate(random.choices(rows, k=100)):
name = package["project"]
# PEP 691
resp = requests.get(f"https://pypi.org/simple/{name}/", headers={"Accept": "application/vnd.pypi.simple.v1+json"})
headers = resp.headers
assert headers["Content-Type"] == "application/vnd.pypi.simple.v1+json"
assert resp.ok
if headers.get("Access-Control-Allow-Origin") != "*":
print(f"({idx}) Fail (json): {name}")
# PEP 503
resp = requests.get(f"https://pypi.org/simple/{name}/", headers={"Accept": "text/html"})
headers = resp.headers
assert headers["Content-Type"] == "text/html"
assert resp.ok
if headers.get("Access-Control-Allow-Origin") != "*":
print(f"({idx}) Fail (html): {name}")
time.sleep(1) Result:
Which is a good news and I think I can continue on #65, as we will avoid using HTML APIs by default (though we will need to support and test it locally). |
Closing as completed, I'll open a separate issue for pep658. |
I've recently started working on changing micropip to use the simple API (PEP 503, PEP 691), instead of legacy JSON API. I think changing to simple API will help people to create alternative package registries following the standard, and we can also benefit from other PyPA tools.
The text was updated successfully, but these errors were encountered: