Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.1: missing install-time dependencies #56

Closed
kloczek opened this issue Oct 3, 2022 · 5 comments · Fixed by #64
Closed

1.3.1: missing install-time dependencies #56

kloczek opened this issue Oct 3, 2022 · 5 comments · Fixed by #64

Comments

@kloczek
Copy link

kloczek commented Oct 3, 2022

During pep440 test suite execution I found that pytest failed because missing pkg_resources module in build env.

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pep440-0.1.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pep440-0.1.2-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
Traceback (most recent call last):
  File "/usr/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 187, in console_main
    code = main()
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 145, in main
    config = _prepareconfig(args, plugins)
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 324, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/usr/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/usr/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 55, in _multicall
    gen.send(outcome)
  File "/usr/lib/python3.8/site-packages/_pytest/helpconfig.py", line 102, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/usr/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1017, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1305, in parse
    self._preparse(args, addopts=addopts)
  File "/usr/lib/python3.8/site-packages/_pytest/config/__init__.py", line 1188, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/usr/lib/python3.8/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib64/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 168, in exec_module
    exec(co, module.__dict__)
  File "/usr/lib/python3.8/site-packages/pytest_console_scripts.py", line 6, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

And indeed in


is import of that module and in
install_requires=['pytest>=4.0.0'],

is missing that install time dependency.

Quirck solution could be patch like below

--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
     long_description=read('README.md'),
     long_description_content_type='text/markdown',
     py_modules=['pytest_console_scripts'],
-    install_requires=['pytest>=4.0.0'],
+    install_requires=['pytest>=4.0.0', 'pkg_resources'],
     python_requires='>=3.6',
     setup_requires=['setuptools-scm'],
     classifiers=[

however basing on pypa/setuptools#3279 better would be migrate to use importlib_metadata like https://git.smhi.se/climix/climix/-/merge_requests/165.patch

@kloczek
Copy link
Author

kloczek commented Oct 3, 2022

That quick patch is incorect. pkg_resources is part of the seuptools however pkg_resources has no any metadata for pkg_resources so correct quick patch should be

--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
     long_description=read('README.md'),
     long_description_content_type='text/markdown',
     py_modules=['pytest_console_scripts'],
-    install_requires=['pytest>=4.0.0'],
+    install_requires=['pytest>=4.0.0', 'setuptools'],
     python_requires='>=3.6',
     setup_requires=['setuptools-scm'],
     classifiers=[

@frenzymadness
Copy link

It'd be nice to fix that. Would a PR speed this up?

HexDecimal added a commit to HexDecimal/pytest-console-scripts that referenced this issue May 12, 2023
Required for the pkg_resources module which is being used.
Closes kvas-it#56

Alternates were discussed but those would require dropping Python
versions before 3.8.
@kloczek
Copy link
Author

kloczek commented May 20, 2023

Any plans to rel;ease new version? 🤔

@HexDecimal
Copy link
Collaborator

I'd like to make a new release after #69 is merged.

@kloczek
Copy link
Author

kloczek commented May 20, 2023

Thx 👍

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 a pull request may close this issue.

3 participants