Skip to content

Declare wasmtime.* packages and exclude .git/ et al when discovering tests - #314

Merged
alexcrichton merged 2 commits into
bytecodealliance:mainfrom
moreati:pytest-excludes
Nov 6, 2025
Merged

alexcrichton merged 2 commits into
bytecodealliance:mainfrom
moreati:pytest-excludes

Conversation

@moreati

@moreati moreati commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

These changes are sufficient for my to run nox successfully. They may also pre-emptively fix future build errors in CI.

The change to pyproject.toml is there to make sure wasmtime.component and any future sub-packages, are included in any sdist, wheel, or editable (e.g. pip -e .) installation.

See

Supercedes #301

…kages)

This switches the strategy from explicitly listing packages, to automatic
discovery by scanning the filesystem - treating the filesystem layout as a
single source of truth.

```console
➜  wasmtime-py git:(pytest-excludes) ✗ uv build --sdist
Building source distribution...
running egg_info
writing wasmtime.egg-info/PKG-INFO
...
copying wasmtime.egg-info/requires.txt -> wasmtime-38.0.0.post11+git.ccf7e2ec.dirty/wasmtime.egg-info
copying wasmtime.egg-info/top_level.txt -> wasmtime-38.0.0.post11+git.ccf7e2ec.dirty/wasmtime.egg-info
copying wasmtime/component/__init__.py -> wasmtime-38.0.0.post11+git.ccf7e2ec.dirty/wasmtime/component
copying wasmtime/component/_component.py -> wasmtime-38.0.0.post11+git.ccf7e2ec.dirty/wasmtime/component
copying wasmtime/component/_enter.py -> wasmtime-38.0.0.post11+git.ccf7e2ec.dirty/wasmtime/component
...
```

See
- https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#auto-discovery
This was interfering with running tests locally, pytest
- scanned .git/ & tried to parse content as Python source
- scanned build/ and found duplicates of e.g. wasmtime/_config.py

This restores the relavant default globs for norecursedirs, that
were previously overridden.

https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-norecursedirs

E.g.
```
__________ ERROR collecting .git/logs/refs/remotes/origin/issue231-src-dist-version_suffix_in_setup.py __________
.venv/lib/python3.9/site-packages/_pytest/python.py:498: in importtestmodule
    mod = import_path(
.venv/lib/python3.9/site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
../../.local/share/uv/python/cpython-3.9.23-macos-aarch64-none/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:846: in exec_module
    ???
<frozen importlib._bootstrap_external>:983: in get_code
    ???
<frozen importlib._bootstrap_external>:913: in source_to_code
    ???
<frozen importlib._bootstrap>:228: in _call_with_frames_removed
    ???
E     File "/Users/alex/src/wasmtime-py/.git/logs/refs/remotes/origin/issue231-src-dist-version_suffix_in_setup.py", line 1
E       0000000000000000000000000000000000000000 61c83b6 Alex Willmer <[email protected]> 1749727258 +0100   update by push
E                                                ^
E   SyntaxError: invalid syntax
```

```
__________ ERROR collecting src/wasmtime/bindgen/generated/imports/stderr.py __________
import file mismatch:
imported module 'wasmtime.bindgen.generated.imports.stderr' has this __file__ attribute:
  /Users/alex/src/wasmtime-py/build/lib/wasmtime/bindgen/generated/imports/stderr.py
which is not the same as the test file we want to collect:
  /Users/alex/src/wasmtime-py/src/wasmtime/bindgen/generated/imports/stderr.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
```
@moreati
moreati marked this pull request as ready for review November 6, 2025 18:48
@alexcrichton
alexcrichton merged commit 5360a87 into bytecodealliance:main Nov 6, 2025
@moreati
moreati deleted the pytest-excludes branch November 7, 2025 00:06
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.

2 participants