MCPcopy Index your code
hub / github.com/RustPython/RustPython / _load_info_pypi

Function _load_info_pypi

crates/wasm/Lib/whlimport.py:63–85  ·  view source on GitHub ↗
(pkg)

Source from the content-addressed store, hash-verified

61
62
63async def _load_info_pypi(pkg):
64 pkg = _microdistlib.parse_requirement(pkg)
65 # TODO: use VersionMatcher from distlib
66 api_url = (
67 f"https://pypi.org/pypi/{pkg.name}/json"
68 if not pkg.constraints
69 else f"https://pypi.org/pypi/{pkg.name}/{pkg.constraints[0][1]}/json"
70 )
71 info = await browser.fetch(api_url, response_format="json")
72 name = info["info"]["name"]
73 ver = info["info"]["version"]
74 ver_downloads = info["releases"][ver]
75 try:
76 dl = next(dl for dl in ver_downloads if dl["packagetype"] == "bdist_wheel")
77 except StopIteration:
78 raise ValueError(f"no wheel available for package {name!r} {ver}")
79 return (
80 name,
81 dl["filename"],
82 dl["url"],
83 dl["size"],
84 info["info"]["requires_dist"] or [],
85 )
86
87
88def format_size(bytes):

Callers 1

_load_packageFunction · 0.85

Calls 2

nextFunction · 0.85
fetchMethod · 0.80

Tested by

no test coverage detected