Skip to content

Commit 443c206

Browse files
Fix index URLs and requirements files again
1 parent 4a7116c commit 443c206

File tree

1 file changed

+16
-8
lines changed
  • packages/pyodide-kernel/py/piplite/piplite

1 file changed

+16
-8
lines changed

packages/pyodide-kernel/py/piplite/piplite/cli.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ async def get_action_kwargs(argv: list[str]) -> tuple[typing.Optional[str], dict
151151
for req_file in args.requirements or []:
152152
context = RequirementsContext()
153153

154+
# If CLI index URL is provided, it should override within-file-level
155+
# index URL for all requirements.
156+
if args.index_url:
157+
context.index_url = args.index_url
158+
154159
if not Path(req_file).exists():
155160
warn(f"piplite could not find requirements file {req_file}")
156161
continue
@@ -165,18 +170,21 @@ async def get_action_kwargs(argv: list[str]) -> tuple[typing.Optional[str], dict
165170
all_requirements.extend(context.requirements)
166171

167172
if all_requirements:
168-
kwargs["requirements"] = []
169-
used_index = None
173+
by_index = {}
174+
file_index_url = None
170175

171176
for req, idx in all_requirements:
172177
if idx:
173-
used_index = idx
174-
kwargs["requirements"].append(req)
178+
file_index_url = idx
179+
by_index.setdefault(file_index_url, []).append(req)
175180

176-
# Set the index URL if one was found (either passed to the CLI or
177-
# passed within the requirements file)
178-
if used_index:
179-
kwargs["index_urls"] = used_index
181+
# Build final kwargs. We set the index URL if one was found
182+
# (either passed to the CLI or passed within the requirements file)
183+
kwargs["requirements"] = []
184+
for idx, reqs in by_index.items():
185+
if idx:
186+
kwargs["index_urls"] = idx
187+
kwargs["requirements"].extend(reqs)
180188

181189
if args.pre:
182190
kwargs["pre"] = True

0 commit comments

Comments
 (0)