Skip to content

Commit

Permalink
try more url checking
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Jan 30, 2025
1 parent d45f62d commit 00e6e7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion micropip/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def validate_constraints(
if req.extras:
messages.append("may not provide [extras]")

if not (req.url or req.specifier):
if not (req.url or len(req.specifier)):
messages.append("no version or URL")

if req.marker and not req.marker.evaluate(environment):
Expand Down
20 changes: 11 additions & 9 deletions micropip/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,24 @@ async def add_requirement(self, req: str | Requirement) -> None:
return await self.add_requirement_inner(req)

try:
req = constrain_requirement(Requirement(req), self.constrained_reqs)
url = req.url
as_req = constrain_requirement(Requirement(req), self.constrained_reqs)
except InvalidRequirement:
url = f"{req}"
as_req = None

if not (url and urlparse(url).path.endswith(".whl")):
return await self.add_requirement_inner(
req if isinstance(req, Requirement) else Requirement(req)
)
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 url:
if urlparse(req).path.endswith(".whl"):
# custom download location
wheel = WheelInfo.from_url(url)
wheel = WheelInfo.from_url(req)
check_compatible(wheel.filename)
return await self.add_wheel(wheel, extras=set(), specifier="")

return await self.add_requirement_inner(Requirement(req))

def check_version_satisfied(self, req: Requirement) -> tuple[bool, str]:
ver = None
try:
Expand Down

0 comments on commit 00e6e7a

Please sign in to comment.