Skip to content

Commit 84584b7

Browse files
committed
test: Allow custom find-links in pip_install_local()
1 parent 18694f6 commit 84584b7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/lib/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,26 @@ def pip(
725725
def pip_install_local(
726726
self,
727727
*args: StrPath,
728+
find_links: StrPath | list[StrPath] = pathlib.Path(DATA_DIR, "packages"),
728729
**kwargs: Any,
729730
) -> TestPipResult:
731+
"""Invoke pip install without PyPI access. By default, only local
732+
packages are included via --find-links."""
733+
# Convert find links paths to absolute file: URIs
734+
if not isinstance(find_links, list):
735+
find_links = [find_links]
736+
find_links_args: list[StrPath] = []
737+
for folder in find_links:
738+
if isinstance(folder, str) and folder.startswith("file:"):
739+
find_links_args.extend(("--find-links", folder))
740+
else:
741+
path = pathlib.Path(folder).resolve()
742+
find_links_args.extend(("--find-links", path.as_uri()))
743+
730744
return self.pip(
731745
"install",
732746
"--no-index",
733-
"--find-links",
734-
pathlib.Path(DATA_DIR, "packages").as_uri(),
747+
*find_links_args,
735748
*args,
736749
**kwargs,
737750
)

0 commit comments

Comments
 (0)