Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit c837dd8

Browse files
committed
Factor out a function to define the pip shell command
Facilitates later features.
1 parent 7abe06b commit c837dd8

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

komodo/cli.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,10 @@ def install_previously_downloaded_pip_packages(
270270
pip_executable: str,
271271
release_root: Path,
272272
) -> None:
273-
for pkg, ver in release_file_content.items():
274-
current = repository_file_content[pkg][ver]
275-
if current["make"] != "pip":
276-
continue
277-
278-
package_name = current.get("pypi_package_name", pkg)
279-
shell_input = [
273+
def pip_shell_command(
274+
package_name: str, ver: str, makeopts: str | None
275+
) -> list[str | None]:
276+
return [
280277
pip_executable,
281278
f"install {package_name}=={strip_version(ver)}",
282279
"--prefix",
@@ -288,9 +285,17 @@ def install_previously_downloaded_pip_packages(
288285
# assuming fetch.py has done "pip download" to this directory:
289286
f"--cache-dir {downloads_directory}",
290287
f"--find-links {downloads_directory}",
288+
makeopts,
291289
]
292-
shell_input.append(current.get("makeopts"))
293290

291+
for pkg, ver in release_file_content.items():
292+
pkg_data = repository_file_content[pkg][ver]
293+
if pkg_data["make"] != "pip":
294+
continue
295+
296+
shell_input = pip_shell_command(
297+
pkg_data.get("pypi_package_name", pkg), ver, pkg_data.get("makeopts")
298+
)
294299
print(shell(shell_input))
295300

296301

komodo/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def pushd(path):
1515
os.chdir(prev)
1616

1717

18-
def shell(cmd: str, allow_failure=False) -> bytes:
18+
def shell(cmd: str | list[str | None], allow_failure=False) -> bytes:
1919
try:
2020
cmdlist = cmd.split(" ")
2121
except AttributeError:

0 commit comments

Comments
 (0)