Skip to content

genlayer-test direct-mode tests are completely broken on Windows (3 separate issues) #99

Description

@JspIIV

Summary

Trying to run genlayer-test's direct-mode pytest fixtures (direct_vm, direct_deploy, etc.) on a stock Windows 11 machine fails in three separate, independent ways depending on which one you work around first. Together they make direct-mode testing completely unusable on Windows out of the box.

Issue 1: ImportError: cannot import name 'Buffer' from 'collections.abc' on Python 3.10

File "...\site-packages\genlayer_py\types\calldata.py", line 4, in <module>
    from collections.abc import Sequence, Mapping, Buffer
ImportError: cannot import name 'Buffer' from 'collections.abc'

collections.abc.Buffer was only added in Python 3.12. genlayer-test (via its genlayer-py dependency) can't even be imported on Python 3.10, with no version constraint in the package metadata warning about this. Worked around by switching to Python 3.12.

Issue 2: SDK download 404s on the current default/latest pinned version

Downloading https://github.com/genlayerlabs/genvm/releases/download/v0.3.0-rc7/genvm-universal.tar.xz...
urllib.error.HTTPError: HTTP Error 404: Not Found

The genvm release v0.3.0-rc7 (currently "Latest") only publishes these assets:

genvm-linux-amd64-executor.tar.xz
genvm-linux-amd64.tar.xz
genvm-linux-arm64-executor.tar.xz
genvm-linux-arm64.tar.xz
genvm-macos-arm64-executor.tar.xz
genvm-macos-arm64.tar.xz
genvm-runners-all.tar.xz

There is no genvm-universal.tar.xz and no Windows-specific asset at all. Older releases (e.g. v0.2.16) DO publish a genvm-universal.tar.xz asset — this looks like a regression where the "universal" (presumably cross-platform, needed for Windows) build was dropped starting somewhere around the v0.3.0-rc* release train. Worked around by explicitly passing sdk_version="v0.2.16" to direct_deploy(...), which is not documented as a fallback anywhere.

Issue 3: os.unlink() on a still-open file fails with PermissionError on Windows

After working around issues 1 and 2, contract deployment itself fails:

File "...\site-packages\gltest\direct\loader.py", line 293, in <module>
    os.unlink(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\...\AppData\Local\Temp\tmp....'

The code creates a temp file, writes encoded calldata to it, os.dup2()s it onto fd 0 (stdin) for a subprocess to read, then immediately calls os.unlink(path) while the duped file descriptor is still open. This pattern works on POSIX (unlinking an open file just removes the directory entry; the data stays available via the open fd) but Windows enforces file locking and refuses to delete a file that still has an open handle, even via a duplicated fd. This needs either os.close() on the original fd before unlinking, delayed cleanup after the subprocess exits, or a Windows-specific temp-file strategy (e.g. tempfile.NamedTemporaryFile(delete=False) + explicit cleanup after the subprocess consuming it has finished, or piping the calldata directly via subprocess.Popen(..., stdin=PIPE) instead of stdin redirection through a temp file).

Environment

  • OS: Windows 11
  • Python: 3.12.2800 (issue 1 also reproduced separately on 3.10.0)
  • genlayer-test version: 0.1.2

Impact

All three issues combined mean genlayer-test's direct-mode pytest fixtures cannot deploy a single contract on a stock Windows setup without manual patching of the installed package or an unsupported SDK version override. This blocks anyone trying to add direct-mode test coverage to a GenLayer contract from a Windows machine, which the direct-tests skill/docs otherwise present as a fully supported first-class workflow ("no server, no Docker — tests run in ~30-50ms").

Ask

  • Add a Python version floor (>=3.12) to package metadata, or drop the Buffer import dependency for broader compatibility.
  • Restore a genvm-universal.tar.xz (or platform-specific Windows) asset in current genvm releases, or make genlayer-test pin/select an SDK version that's known to have a working asset for the host platform instead of always defaulting to "latest".
  • Fix the temp-file lifecycle in gltest/direct/loader.py (~line 293) to be Windows-safe (close-before-unlink, or defer cleanup, or avoid stdin-via-tempfile entirely).

Activity

  1. ygd58 commented on Aug 1, 2026

    @ygd58

    Opened #104 fixing bug 3 (Windows PermissionError on the stdin temp-file unlink) — deferred the unlink to VMContext._cleanup_after_deactivate(), after fd 0's duplicate is actually closed, instead of unlinking immediately while fd 0 still references the file.

    Bugs 1 and 2 are outside this repo (genlayer-py's Buffer import, and the missing genvm-universal.tar.xz release asset), so this PR only covers bug 3.

  2. ygd58 commented on Aug 1, 2026

    @ygd58

    Status update on bugs 1 and 2 (bug 3 was fixed in #104):

    Bug 1 (collections.abc.Buffer ImportError on Python 3.10) — already fixed

    Verified directly against the published PyPI packages, not just repo source:

    genlayer-py 0.18.0   requires_python: >=3.12
    genlayer-test 0.29.2 requires_python: >=3.12
    

    Both now correctly declare a >=3.12 floor. pip install genlayer-test on Python 3.10 will refuse to install with a clear "not compatible with this Python" error instead of installing and crashing on the Buffer import deep in calldata.py. (The Buffer import itself is still unguarded in genlayer_py/types/calldata.py and genlayer_py/abi/calldata/decoder.py — only ever used as a type annotation, never at runtime — but since requires-python now blocks installation on <3.12 entirely, there's no user-facing path left to hit the crash. The 0.1.2 version in the original report predates this floor by ~25 releases.)

    Bug 2 (missing genvm-universal.tar.xz / Windows asset) — still broken, but the fix is already built, just not shipped

    Confirmed genlayerlabs/genvm's v0.3.0-rc7 (still "Latest") has no genvm-universal.tar.xz and no Windows asset — same 7 assets as in the original report.

    genvm is now archived (moved to genvm-manager), and genvm-manager has zero releases published so far. But its .github/workflows/release.yaml already fully implements producing a genvm-universal.tar.xz asset again — the workflow's own header comment describes it explicitly:

    genvm-universal.tar.xz — shared runners under runners/ + legacy lines'
                             runners at executor/<version>/legacy-runners
    

    So this isn't a design gap that needs new work — it's a release that hasn't been cut yet. Once genvm-manager publishes its first release, this should resolve itself. Worth flagging to whoever owns that migration, since genlayer-testing-suite's SDK-download fallback currently only knows about genlayerlabs/genvm releases (per genvm-linter's equivalent logic checking RUNNER_BUNDLE_ASSETS = ("genvm-runners-all.tar.xz", "genvm-universal.tar.xz")) and will need to point at genvm-manager once that repo starts publishing.

    I don't have write access to either release pipeline, so no PR from me on bug 2 — just flagging the concrete state so it's not mistaken for unstarted work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions