Skip to content

CI: Fix module discovery when using spin test flags - #8173

Merged
stefanv merged 16 commits into
scikit-image:mainfrom
blink1073:fix-test-modified
May 21, 2026
Merged

stefanv merged 16 commits into
scikit-image:mainfrom
blink1073:fix-test-modified

Conversation

@blink1073

@blink1073 blink1073 commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Partial fix for #8166.

The only contentious part I think is the addition of the pythonpath pytest config. It is there to add ./tests to the path while avoiding having to put __init__.py files in every test directory when running against an out-of-tree build. It has no affect on the ./src folder (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.

@greptile-apps

greptile-apps Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "add ability to run --test-modified local..." | Re-trigger Greptile

Comment thread pyproject.toml Resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Update pyproject.toml" | Re-trigger Greptile

Comment thread .spin/cmds.py Outdated
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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracking branch of the current branch: the branch being tracked by the current branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread .spin/cmds.py Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread .spin/cmds.py Outdated
# skimage._shared) may not exist as importable packages in the
# installed wheel.
installed_mod = (
'_skimage2' + mod[len('skimage2') :]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'_skimage2' + mod[len('skimage2') :]
'_skimage2' + mod[len('skimage2'):]

Huh, ruff didn't complain?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better as mod.replace(_skimage2, skimage2)` for readability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread .spin/cmds.py Resolved
Comment thread pyproject.toml
[tool.pytest.ini_options]
minversion = "6.0"
minversion = "7.0"
pythonpath = ["."]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this confusing: isn't the package installed when you have an editable install?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment

@blink1073 blink1073 mentioned this pull request May 19, 2026
1 task done
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile

Comment thread CONTRIBUTING.rst Outdated
.. code-block:: shell

spin install
spin test --installed -- tests/skimage/morphology

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new requirement? spin test used to work fine with both installed and non-installed versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we can use path detection instead of an --installed flag. I updated the branch.

@stefanv stefanv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two quick q's; otherwise looks good to go.

Comment thread pyproject.toml
[tool.pytest.ini_options]
minversion = "6.0"
minversion = "7.0"
pythonpath = ["."]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this confusing: isn't the package installed when you have an editable install?

@greptile-apps

greptile-apps Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (4): Last reviewed commit: "use autodetection logic instead of an --..." | Re-trigger Greptile

Comment thread .spin/cmds.py Resolved
@blink1073

Copy link
Copy Markdown
Contributor Author

I'll verify that the new label checker works here as well.

@greptile-apps

greptile-apps Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (5): Last reviewed commit: "Merge branch 'main' into fix-test-modifi..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (6): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile

Comment thread src/_skimage2/feature/_canny.py Resolved
@blink1073 blink1073 added the 🧪 run-all-tests Run all of the tests, instead of only those in subpackages that have been modified by the PR label May 20, 2026
@blink1073

Copy link
Copy Markdown
Contributor Author

I'll verify that the new label checker works here as well.

Works as expected. This is ready for another look.

@blink1073
blink1073 requested a review from stefanv May 20, 2026 14:28
@greptile-apps

greptile-apps Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (7): Last reviewed commit: "undo trigger" | Re-trigger Greptile

Comment thread .spin/cmds.py Resolved
@greptile-apps

greptile-apps Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviews (8): Last reviewed commit: "address greptile review" | Re-trigger Greptile

@stefanv stefanv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is close now that the --installed flag is gone.

Comment thread .spin/cmds.py
"""


def _is_wheel_install():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 False

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .spin/cmds.py
):
pytest_args = kwargs.get('pytest_args', ())

# Detect whether we're running against a pip-installed wheel by checking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is correct, but it is not implemented in _is_wheel_install

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Reviews (9): Last reviewed commit: "address review" | Re-trigger Greptile

Comment thread .spin/cmds.py Resolved
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Reviews (10): Last reviewed commit: "Update .spin/cmds.py" | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Reviews (11): Last reviewed commit: "Merge branch 'fix-test-modified' of gith..." | Re-trigger Greptile

@stefanv
stefanv merged commit 005bc41 into scikit-image:main May 21, 2026
26 checks passed
@stefanv

stefanv commented May 21, 2026

Copy link
Copy Markdown
Member

Excellent, thanks!

@stefanv stefanv added this to the 0.27 milestone May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug 🤖 type: Infrastructure CI, packaging, tools and automation 🧪 run-all-tests Run all of the tests, instead of only those in subpackages that have been modified by the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants