Skip to content

Commit

Permalink
Merge pull request #54 from craig8/feature/enhance-install_library
Browse files Browse the repository at this point in the history
Added whl and src installation to install_library
  • Loading branch information
craig8 authored Oct 29, 2024
2 parents 9c834fb + daf1e2f commit ca1dda0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/volttrontesting/platformwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ca1dda0

Please sign in to comment.