Skip to content

Let QLDPC_GAP_COMMAND choose the command that runs GAP, and document GAP on Windows - #1061

Merged
perlinm merged 8 commits into
mainfrom
feat/gap-command
Nov 25, 2026
Merged

perlinm merged 8 commits into
mainfrom
feat/gap-command

Conversation

@perlinm

@perlinm perlinm commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Issue #294 reports that a Windows user with the official GAP installer could not use GAP from qLDPC, and that conda install -c conda-forge gap fails on Windows. Neither route can work today: passagemath-gap publishes no Windows wheels, conda-forge builds GAP only for Linux and macOS, and the GAP installer for Windows runs GAP inside a bundled Cygwin through gap.bat, adding no gap command. Without passagemath-gap, qLDPC could only start GAP as a bare gap on PATH. This pull request does not make GAP work on Windows, so it refers to #294 without closing it. It lets users point qLDPC at a GAP that is not on PATH, on any platform, and documents the options on Windows.

Changes

The environment variable QLDPC_GAP_COMMAND now sets the launch command with which qLDPC starts GAP as a separate program; unset or blank, qLDPC runs gap as before, and passagemath-gap still takes precedence. qLDPC splits the launch command at whitespace outside double quotes and removes the double quotes, keeping every other character, so Windows paths need no escaping; an unmatched quote raises a ValueError. The qldpc.external.gap module docstring holds the full contract: when qLDPC uses the launch command, how it is split, which GAP options qLDPC appends, and what a wrapper must do. A wrapper must pass on those options and standard input, and write nothing of its own to standard output or standard error. GAP must also be able to open qLDPC's package directory as a path on the system where Python runs. The installation guide, the library map, and ClassicalCode.from_name point to that docstring. "Launch command" is kept distinct from "commands", which in this module means GAP code, as in get_output(*commands).

GAP processes no longer inherit Python's standard input. With a user-chosen launch command, a wrapper that ignores its arguments would otherwise start an interactive GAP that waits for input, which could hang is_callable(), a check meant to be safe for automatic backend selection. The availability check now treats any OSError from starting the launch command as "not callable", and the prompt shown when GAP cannot be called prints the launch command as written.

The installation guide gains a "GAP on Windows" section. It says what is unavailable, recommends running qLDPC inside WSL (as the GAP developers recommend for GAP), where pip install 'qldpc[gap]' works, and notes that the copy/paste fallback works with the installer's GAP console. It also stops suggesting conda-forge on Windows. Several nearby docstrings that described the GAP backends inaccurately are corrected, such as the return value of is_installed after the user agrees to the manual workflow, and when get_output raises FileNotFoundError.

Testing

Nothing here was run on Windows. test_command checks the following:

  • the splitting rule on a Windows path;
  • the default launch command;
  • that both the availability check and GAP evaluations start with the launch command, and get no input from Python's standard input;
  • the prompt;
  • re-checking after clear_cache();
  • the parse error.

test_get_output checks that GAP code goes in -c normally and on standard input with use_pipe=True. Mutation checks confirmed that these tests fail without the closed standard input, with # treated as a comment, with the old prompt quoting, or with code always sent through -c. Running the availability check with a launch command that reads standard input, under sleep 6 | ..., now returns at once instead of blocking for the full 6 seconds.

Additional notes

Whether some launch command runs the installer's Cygwin GAP from Windows Python is untested, so the docs give no Windows recipe. The installer's gap.bat cannot serve as one, since it ignores its arguments. A Windows user could try a launch command and report on #294.

perlinm and others added 8 commits November 25, 2026 15:40
…GAP on Windows

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… written

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…us references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… name for each GAP concept

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e separate-program backend

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…xactly

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@perlinm
perlinm merged commit 81f9959 into main Nov 25, 2026
10 checks passed
@perlinm
perlinm deleted the feat/gap-command branch November 25, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant