From daf1e2feb9b46b97d089baee4e8268e850cf21f8 Mon Sep 17 00:00:00 2001 From: "C. Allwardt" <3979063+craig8@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:15:07 -0700 Subject: [PATCH] Added whl and src installation to install_library --- src/volttrontesting/platformwrapper.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/volttrontesting/platformwrapper.py b/src/volttrontesting/platformwrapper.py index 1d6a40b..5912aa0 100644 --- a/src/volttrontesting/platformwrapper.py +++ b/src/volttrontesting/platformwrapper.py @@ -520,13 +520,23 @@ def run_command(self, cmd: list, cwd: Path | str = None) -> str: def install_library(self, library: str | Path, version: str = "latest"): if isinstance(library, Path): - # Install locally could be a wheel or a pyproject.toml project - raise NotImplemented("Local path library is available yet.") - - if version != "latest": - cmd = f"poetry add {library}=={version}" + library = library.resolve() # Ensure we have an absolute path + if library.is_file() and library.suffix == ".whl": + # Install the wheel file directly + cmd = f"poetry add {library}" + elif library.is_dir() and (library / "pyproject.toml").exists(): + # Install from a directory with pyproject.toml + cmd = f"poetry add {library}" + elif library.is_dir() and (library / "setup.py").exists(): + # Install from a directory with setup.py (legacy support) + cmd = f"poetry add {library}" + else: + raise ValueError("The specified path is not a valid wheel file or project directory.") else: - cmd = f"poetry add {library}@latest" + if version != "latest": + cmd = f"poetry add {library}=={version}" + else: + cmd = f"poetry add {library}@latest" try: output = self._virtual_env.run(args=cmd, env=self._platform_environment, capture=True,