Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added whl and src installation to install_library #54

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading