Skip to content

Commit 900feb7

Browse files
committed
install: Support "pkg @ https://…/pkg.whl" syntax
Closes: #205
1 parent 65f4c2f commit 900feb7

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

micropip/transaction.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,15 @@ async def add_requirement(self, req: str | Requirement) -> None:
8080
try:
8181
as_req = constrain_requirement(Requirement(req), self.constrained_reqs)
8282
except InvalidRequirement:
83-
as_req = None
84-
85-
if as_req:
86-
if as_req.name and len(as_req.specifier):
87-
return await self.add_requirement_inner(as_req)
88-
if as_req.url:
89-
req = as_req.url
90-
91-
if urlparse(req).path.endswith(".whl"):
92-
# custom download location
93-
wheel = WheelInfo.from_url(req)
94-
check_compatible(wheel.filename)
95-
return await self.add_wheel(wheel, extras=set(), specifier="")
83+
if urlparse(req).path.endswith(".whl"):
84+
# custom download location
85+
wheel = WheelInfo.from_url(req)
86+
check_compatible(wheel.filename)
87+
return await self.add_wheel(wheel, extras=set(), specifier="")
88+
else:
89+
raise
9690

97-
return await self.add_requirement_inner(Requirement(req))
91+
return await self.add_requirement_inner(as_req)
9892

9993
def check_version_satisfied(
10094
self, req: Requirement, *, allow_reinstall: bool = False
@@ -201,6 +195,11 @@ def eval_marker(e: dict[str, str]) -> bool:
201195
logger.info("Requirement already satisfied: %s (%s)", req, ver)
202196
return
203197

198+
if req.url:
199+
wheel = WheelInfo.from_url(req.url)
200+
check_compatible(wheel.filename)
201+
return await self.add_wheel(wheel, extras=req.extras, specifier="")
202+
204203
try:
205204
if self.search_pyodide_lock_first:
206205
if await self._add_requirement_from_pyodide_lock(req):

0 commit comments

Comments
 (0)