Skip to content

Commit

Permalink
test: figure out what goes wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
davhofer committed Sep 2, 2024
1 parent 8ff646d commit 3c35e28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: echo $SPACK_ROOT

- name: Check py-hatchling
run: spack list py-hatchling
run: $SPACK_ROOT/bin/spack list py-hatchling

- name: Run tests
run: python -m pytest
10 changes: 3 additions & 7 deletions src/py2spack/spack_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def package_exists_in_spack(name: str) -> bool:
The function relies on the `spack list` cli command, thus all repositories
known to Spack will be considered (but only those).
"""
result = run_spack_command(f"spack list {name}")
# result = run_spack_command(f"spack list {name}")
result = run_spack_command(f"$SPACK_ROOT/bin/spack list {name}")
if result is not None:
pattern = r"(\b)(?<!-)" + re.escape(name) + r"(?!-)\b"
return re.search(pattern, result) is not None
Expand All @@ -28,12 +29,7 @@ def is_spack_repo(repo: pathlib.Path) -> bool:

def run_spack_command(command: str) -> None | str:
"""Run spack command and return stdout."""
command_list = command.split(" ")
if command_list[0] != "spack":
command_list.insert(0, "spack")

cmd = " ".join(command_list)
return subprocess.run(cmd, capture_output=True, text=True, shell=True, check=False).stdout
return subprocess.run(command, capture_output=True, text=True, shell=True, check=False).stdout


def get_spack_repo(repo_path: str | None) -> pathlib.Path:
Expand Down

0 comments on commit 3c35e28

Please sign in to comment.