pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.23k stars 121 forks source link

Bug: Pluggy 1.4 searches all home dirs for __init__.py #480

Closed psa closed 6 months ago

psa commented 6 months ago

When doing a conda build, we have noticed an issue where pluggy 1.4 searches all home directories for init.py. Reverting to Pluggy 1.3 fixes the issue.

Here's the stack trace:

$PREFIX/lib/python3.12/site-packages/pluggy/_hooks.py:501: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
$PREFIX/lib/python3.12/site-packages/pluggy/_manager.py:119: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
$PREFIX/lib/python3.12/site-packages/_pytest/python.py:210: in pytest_collect_directory
    if pkginit.is_file():
$PREFIX/lib/python3.12/pathlib.py:892: in is_file
    return S_ISREG(self.stat().st_mode)
$PREFIX/lib/python3.12/pathlib.py:840: in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
E   PermissionError: [Errno 13] Permission denied: '${path_to_homedir_of_user}/__init__.py'

The project being tested is a pretty straight forward use of pytest:

requirements:
    host:
        - python>=3.8.8
    run:
        - python>=3.8.8
        - pyyaml
        - jsonschema

test:
    imports:
        - ${project_name}
    commands:
        - pytest --pyargs ${project_name}
        - source ${project_name}
    requires:
        # Pluggy 1.4 attempts to search all home dirs for __init__.py
        - pluggy <1.4
        - pytest
RonnyPfannschmidt commented 6 months ago

What's The pytest version each time

The code triggering the walk is in pytest, I believe that pytest 8 vs 7 is the actual issue

bluetech commented 6 months ago

Yes, there will be some solution for this for pytest 8.1 hopefully.