Skip to content

Support running pytest under WASI #10670

Open
@brettcannon

Description

@brettcannon

What's the problem this feature will solve?

I'm trying to run pytest under the WASI build of CPython, but pytest's extensive use of os.dup() prevents it from working.

If you're curious to reproduce:

  1. Grab a WASI build from https://github.com/tiran/cpython-wasm-test/releases
  2. Unpack it somewhere
  3. From the same directory where you unpacked python.wasm: PIP_REQUIRE_VIRTUALENV=0 py -3.11 -m pip install --target . --only-binary=:all: --implementation=py --abi=none --abi=any pytest (if you don't have the Python Launcher, take out -3.11 and add the pip flag --python_version="3.11")
  4. Try running wasmtime run --dir=. python.wasm -- -m pytest -h

It looks like:

self.targetfd_save = os.dup(targetfd)

is the first instance of os.dup() you run into, but even with --capture=no/s, you still run into:

stderr_fd_copy = os.dup(get_stderr_fileno())

Describe the solution you'd like

I would love to be able to provide instructions to projects on how to run pytest under WASI to see if their project is compatible.

Alternative Solutions

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: wasm/wasirelated to WebAssembly supporttype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions