Repository navigation
CI: Fix module discovery when using spin test flags - #8173
Conversation
|
Reviews (1): Last reviewed commit: "add ability to run --test-modified local..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Reviews (2): Last reviewed commit: "Update pyproject.toml" | Re-trigger Greptile |
| if not base_ref: | ||
| base_ref = os.environ.get('GITHUB_BASE_REF') | ||
| if not base_ref and not os.environ.get('GITHUB_ACTIONS'): | ||
| # Locally, use the tracking branch of the current branch (e.g. origin/main). |
There was a problem hiding this comment.
tracking branch of the current branch: the branch being tracked by the current branch?
| When *installed* is True, doctest paths are returned as module names | ||
| (e.g. ``skimage.metrics``) rather than ``src/`` filesystem paths, so | ||
| that pytest with ``--pyargs`` collects doctests from the installed | ||
| package in site-packages. This avoids a ``warn_external`` mismatch |
There was a problem hiding this comment.
This last part may be a bit hard to parse for people unfamiliar with the warn_external internals, but I can't really think of a simpler way to state it.
| # skimage._shared) may not exist as importable packages in the | ||
| # installed wheel. | ||
| installed_mod = ( | ||
| '_skimage2' + mod[len('skimage2') :] |
There was a problem hiding this comment.
| '_skimage2' + mod[len('skimage2') :] | |
| '_skimage2' + mod[len('skimage2'):] |
Huh, ruff didn't complain?
There was a problem hiding this comment.
Maybe better as mod.replace(_skimage2, skimage2)` for readability?
| [tool.pytest.ini_options] | ||
| minversion = "6.0" | ||
| minversion = "7.0" | ||
| pythonpath = ["."] |
There was a problem hiding this comment.
I know you mentioned this in the PR description, but can you explain in a bit more detail? Perhaps a comment here would be useful.
There was a problem hiding this comment.
I find this confusing: isn't the package installed when you have an editable install?
There was a problem hiding this comment.
I updated the comment
… into fix-test-modified
|
Reviews (3): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile |
| .. code-block:: shell | ||
|
|
||
| spin install | ||
| spin test --installed -- tests/skimage/morphology |
There was a problem hiding this comment.
This is a new requirement? spin test used to work fine with both installed and non-installed versions.
There was a problem hiding this comment.
Good catch, we can use path detection instead of an --installed flag. I updated the branch.
stefanv
left a comment
There was a problem hiding this comment.
Two quick q's; otherwise looks good to go.
| [tool.pytest.ini_options] | ||
| minversion = "6.0" | ||
| minversion = "7.0" | ||
| pythonpath = ["."] |
There was a problem hiding this comment.
I find this confusing: isn't the package installed when you have an editable install?
|
Reviews (4): Last reviewed commit: "use autodetection logic instead of an --..." | Re-trigger Greptile |
|
I'll verify that the new label checker works here as well. |
|
Reviews (5): Last reviewed commit: "Merge branch 'main' into fix-test-modifi..." | Re-trigger Greptile |
|
Reviews (6): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile |
Works as expected. This is ready for another look. |
|
Reviews (7): Last reviewed commit: "undo trigger" | Re-trigger Greptile |
|
Reviews (8): Last reviewed commit: "address greptile review" | Re-trigger Greptile |
stefanv
left a comment
There was a problem hiding this comment.
Nice, this is close now that the --installed flag is gone.
| """ | ||
|
|
||
|
|
||
| def _is_wheel_install(): |
There was a problem hiding this comment.
Is this function doing the right thing?
I haven't checked how it is used, but it is basically just checking that skimage is not and editable install, and that it is installed into a site-packages. However, this should also be true for the case where you do in-tree build and set the PYTHONPATH.
If you want to check for wheel explicitly, you could do something like:
import importlib.metadata
try:
dist = importlib.metadata.distribution("skimage")
is_wheel = any("WHEEL" in str(f) for f in dist.files)
return is_wheel
except importlib.metadata.PackageNotFoundError:
return FalseThere was a problem hiding this comment.
This didn't quite work because editable installs also had a WHEEL file. I added a check for the direct_url.json file, and tested the following cases locally:
| State | _is_wheel_install() |
|---|---|
| Meson build (PYTHONPATH only, no metadata) | False |
spin install (editable) |
False |
spin install --no-editable / wheel install |
True |
| ): | ||
| pytest_args = kwargs.get('pytest_args', ()) | ||
|
|
||
| # Detect whether we're running against a pip-installed wheel by checking |
There was a problem hiding this comment.
This logic is correct, but it is not implemented in _is_wheel_install
|
Reviews (9): Last reviewed commit: "address review" | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Reviews (10): Last reviewed commit: "Update .spin/cmds.py" | Re-trigger Greptile |
|
Reviews (11): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile |
|
Excellent, thanks! |
Partial fix for #8166.
--installedflag with path-based discovery of out-of-tree builds.--test-modifiedand out-of-tree builds.--test-modifiedlocally.--test-modifiedlocally in the contributor guide on top of docs: make source install instructions more discoverable and add build requirements to top level requirements file #8165.The only contentious part I think is the addition of the
pythonpathpytestconfig. It is there to add./teststo the path while avoiding having to put__init__.pyfiles in every test directory when running against an out-of-tree build. It has no affect on the./srcfolder (a nice benefit of using that layout). I added a comment inline.AI Usage
This PR was developed with the assistance of Claude Code (claude-sonnet-4-6).
I (@blink1073) have thoroughly reviewed the changes.