From 900feb7f41ef271f0e9ebcf88e2933cb630685fd Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 17 Sep 2025 21:30:06 +0200 Subject: [PATCH 1/2] =?UTF-8?q?install:=20Support=20"pkg=20@=20https://?= =?UTF-8?q?=E2=80=A6/pkg.whl"=20syntax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://github.com/pyodide/micropip/issues/205 --- micropip/transaction.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/micropip/transaction.py b/micropip/transaction.py index abadffb..e58c736 100644 --- a/micropip/transaction.py +++ b/micropip/transaction.py @@ -80,21 +80,15 @@ async def add_requirement(self, req: str | Requirement) -> None: try: as_req = constrain_requirement(Requirement(req), self.constrained_reqs) except InvalidRequirement: - as_req = None - - if as_req: - if as_req.name and len(as_req.specifier): - return await self.add_requirement_inner(as_req) - if as_req.url: - req = as_req.url - - if urlparse(req).path.endswith(".whl"): - # custom download location - wheel = WheelInfo.from_url(req) - check_compatible(wheel.filename) - return await self.add_wheel(wheel, extras=set(), specifier="") + if urlparse(req).path.endswith(".whl"): + # custom download location + wheel = WheelInfo.from_url(req) + check_compatible(wheel.filename) + return await self.add_wheel(wheel, extras=set(), specifier="") + else: + raise - return await self.add_requirement_inner(Requirement(req)) + return await self.add_requirement_inner(as_req) def check_version_satisfied( self, req: Requirement, *, allow_reinstall: bool = False @@ -201,6 +195,11 @@ def eval_marker(e: dict[str, str]) -> bool: logger.info("Requirement already satisfied: %s (%s)", req, ver) return + if req.url: + wheel = WheelInfo.from_url(req.url) + check_compatible(wheel.filename) + return await self.add_wheel(wheel, extras=req.extras, specifier="") + try: if self.search_pyodide_lock_first: if await self._add_requirement_from_pyodide_lock(req): From 6a739e5326e8cb1409fc57c34575399f6fc55da9 Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 17 Sep 2025 21:40:05 +0200 Subject: [PATCH 2/2] transaction: Split overly complex function ruff said so (C901) --- micropip/transaction.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/micropip/transaction.py b/micropip/transaction.py index e58c736..5fb6ac0 100644 --- a/micropip/transaction.py +++ b/micropip/transaction.py @@ -199,7 +199,13 @@ def eval_marker(e: dict[str, str]) -> bool: wheel = WheelInfo.from_url(req.url) check_compatible(wheel.filename) return await self.add_wheel(wheel, extras=req.extras, specifier="") + else: + await self._add_requirement_by_name(req) + async def _add_requirement_by_name( + self, + req: Requirement, + ) -> None: try: if self.search_pyodide_lock_first: if await self._add_requirement_from_pyodide_lock(req):