mirror of https://github.com/pyodide/pyodide.git
Raise error when trying to install a non-pure python wheel (#1859)
This commit is contained in:
parent
d25bbb70fe
commit
bf024c98e0
|
@ -48,6 +48,11 @@ substitutions:
|
|||
- {{ Enhancement }} Better support for ccache when building Pyodide
|
||||
{pr}`1805`
|
||||
|
||||
### micropip
|
||||
|
||||
- {{Fix}} micropip now raises error when installing non-pure python wheel directly from url.
|
||||
{pr}`1859`
|
||||
|
||||
### packages
|
||||
|
||||
- {{ Enhancement }} Unit tests are now unvendored from Python packages and
|
||||
|
|
|
@ -92,6 +92,10 @@ async def _get_pypi_json(pkgname):
|
|||
return json.load(fd)
|
||||
|
||||
|
||||
def _is_pure_python_wheel(filename: str):
|
||||
return filename.endswith("py3-none-any.whl")
|
||||
|
||||
|
||||
def _parse_wheel_url(url: str) -> Tuple[str, Dict[str, Any], str]:
|
||||
"""Parse wheels URL and extract available metadata
|
||||
|
||||
|
@ -205,6 +209,9 @@ class _PackageManager:
|
|||
# custom download location
|
||||
name, wheel, version = _parse_wheel_url(requirement)
|
||||
name = name.lower()
|
||||
if not _is_pure_python_wheel(wheel["filename"]):
|
||||
raise ValueError(f"'{wheel['filename']}' is not a pure Python 3 wheel")
|
||||
|
||||
await self.add_wheel(name, wheel, version, (), ctx, transaction)
|
||||
return
|
||||
else:
|
||||
|
@ -264,7 +271,7 @@ class _PackageManager:
|
|||
for ver in candidate_versions:
|
||||
release = releases[str(ver)]
|
||||
for fileinfo in release:
|
||||
if fileinfo["filename"].endswith("py3-none-any.whl"):
|
||||
if _is_pure_python_wheel(fileinfo["filename"]):
|
||||
return fileinfo, ver
|
||||
|
||||
raise ValueError(f"Couldn't find a pure Python 3 wheel for '{req}'")
|
||||
|
|
|
@ -166,6 +166,19 @@ def test_last_version_from_pypi():
|
|||
assert str(ver) == "0.15.5"
|
||||
|
||||
|
||||
def test_install_non_pure_python_wheel():
|
||||
pytest.importorskip("packaging")
|
||||
from micropip import micropip
|
||||
|
||||
msg = "not a pure Python 3 wheel"
|
||||
with pytest.raises(ValueError, match=msg):
|
||||
url = "http://scikit_learn-0.22.2.post1-cp35-cp35m-macosx_10_9_intel.whl"
|
||||
transaction = {"wheels": [], "locked": {}}
|
||||
asyncio.get_event_loop().run_until_complete(
|
||||
micropip.PACKAGE_MANAGER.add_requirement(url, {}, transaction)
|
||||
)
|
||||
|
||||
|
||||
def test_install_different_version(selenium_standalone_micropip):
|
||||
selenium = selenium_standalone_micropip
|
||||
selenium.run_js(
|
||||
|
|
Loading…
Reference in New Issue