Skip to content

setuptools <82 needed as depending on pkg_resources#14302

Closed
Barry1 wants to merge 7 commits intopytest-dev:mainfrom
Barry1:main
Closed

setuptools <82 needed as depending on pkg_resources#14302
Barry1 wants to merge 7 commits intopytest-dev:mainfrom
Barry1:main

Conversation

@Barry1
Copy link

@Barry1 Barry1 commented Mar 18, 2026

  • For pytest pkg_resources is needed. From setuptools beginning with version 82 pkg_resources is not longer available.

@Barry1 Barry1 marked this pull request as draft March 18, 2026 08:49
@Barry1
Copy link
Author

Barry1 commented Mar 18, 2026

Unfortunately Changelog entry and pre-commit.ci fail - but I do not understand, why. That is strange.

@Barry1 Barry1 marked this pull request as ready for review March 18, 2026 08:50
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

the support for pkg_resources is dealing with legacy messes - if we have a code path outside of tests that actually needs it thats a bug

i did a preliminary check and the only code paths i found where sys.modules check guarded sections for handling legacy details in monkeypatch pythonpath handling and assertion rewrite handling

we should have a conditional skip for related tests and eventually phase it out alltogether

additionally build requires and requries don't match - please provide a a example of the errors you see

@Barry1
Copy link
Author

Barry1 commented Mar 18, 2026

the support for pkg_resources is dealing with legacy messes - if we have a code path outside of tests that actually needs it thats a bug

i did a preliminary check and the only code paths i found where sys.modules check guarded sections for handling legacy details in monkeypatch pythonpath handling and assertion rewrite handling

we should have a conditional skip for related tests and eventually phase it out alltogether

additionally build requires and requries don't match - please provide a a example of the errors you see

Hi @RonnyPfannschmidt ,
thx for the quick reply.
I use pytest with some plugins
plugins: typeguard-4.5.1, cov-7.0.0, pyright-0.0.6, black-0.6.0, anyio-4.12.1, colordots-1.1, mypy-1.0.1, sugar-1.1.1, monkeytype-1.1.0, bandit-0.6.1, pylama-8.4.1, beartype-0.2.0

When using setuptools 81.0.0 it runs smooth, when switching to setuptools 82.0.1 I got the following error

File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/bin/pytest", line 8, in <module>
    sys.exit(console_main())
             ^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/config/__init__.py", line 223, in console_main
    code = main()
           ^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/config/__init__.py", line 193, in main
    config = _prepareconfig(new_args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/config/__init__.py", line 361, in _prepareconfig
    config: Config = pluginmanager.hook.pytest_cmdline_parse(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_hooks.py", line 512, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_callers.py", line 167, in _multicall
    raise exception
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
    teardown.throw(exception)
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/helpconfig.py", line 124, in pytest_cmdline_parse
    config = yield
             ^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_callers.py", line 121, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1186, in pytest_cmdline_parse
    self.parse(args)
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/config/__init__.py", line 1539, in parse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pluggy/_manager.py", line 416, in load_setuptools_entrypoints
    plugin = ep.load()
             ^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/python/3.12.10-5b8d2cca60be0ecc84e000adc8b4947e/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ebeling/.cache/trunk/tools/python/3.12.10-5b8d2cca60be0ecc84e000adc8b4947e/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/assertion/rewrite.py", line 197, in exec_module
    exec(co, module.__dict__)
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pylama/pytest.py", line 9, in <module>
    from pylama.config import CURDIR
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/assertion/rewrite.py", line 197, in exec_module
    exec(co, module.__dict__)
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pylama/config.py", line 13, in <module>
    from pylama.lint import LINTERS
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/_pytest/assertion/rewrite.py", line 197, in exec_module
    exec(co, module.__dict__)
  File "/home/ebeling/.cache/trunk/tools/poetry/2.3.2-3ff4de47fb042985c5aed30280248ddd/lib/python3.12/site-packages/pylama/lint/__init__.py", line 10, in <module>
    from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'

It also happened with python3.13 (in my poetry env).
I just recognized, that by removing pylama it runs fine. So it might be a problem between pytest and pylama?

Thanks again

Bastian

@RonnyPfannschmidt
Copy link
Member

as per traceback the offending code is solely in the other library - pytest is not involved, only the messenger

@RonnyPfannschmidt
Copy link
Member

further context - that package ships a pytest plugin which does the ill advised job of integrating linters in a testruner/framework

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