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

Remove 'script' dependency #124

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions qldpc/external/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
limitations under the License.
"""

import os
import re
import subprocess
import urllib.error
Expand Down Expand Up @@ -114,10 +113,9 @@ def get_generators_from_groupnames(group: str) -> GENERATORS_LIST | None:

def gap_is_installed() -> bool:
"""Is GAP 4 installed?"""
commands = ["script", "-c", "gap --version", os.devnull]
commands = ["gap", "-q", "-c", r'Print(GAPInfo.Version, "\n"); QUIT;']
result = subprocess.run(commands, capture_output=True, text=True)
lines = result.stdout.splitlines()
return len(lines) == 2 and lines[1].startswith("GAP 4")
return bool(re.match(r"\n4\.[0-9]+\.[0-9]+$", result.stdout))


def sanitize_gap_commands(commands: Sequence[str]) -> tuple[str, ...]:
Expand Down
2 changes: 1 addition & 1 deletion qldpc/external/groups_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_gap_is_installed() -> None:
"""Is GAP 4 installed?"""
with unittest.mock.patch("subprocess.run", return_value=get_mock_process("")):
assert not external.groups.gap_is_installed()
with unittest.mock.patch("subprocess.run", return_value=get_mock_process("\nGAP 4")):
with unittest.mock.patch("subprocess.run", return_value=get_mock_process("\n4.12.1")):
assert external.groups.gap_is_installed()


Expand Down