pytest-dev / pytest-dev/pluggy
Silently eats DistributionNotFound errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 160
- Avg merge
- 21h 4m
- Merged PRs (30d)
- 6
Description
I was running into an issue with pluggy, because it eats DistributionNotFound errors. In my case, this prevented most of my installed pytest plugins from being used, without any indication as to why.
The root cause of the DistributionNotFound error was a missing dependency. I installed pytest from a [Pipfile.lock] that was (presumably) generated on a Unix system, where pytest does not depend on the colorama package. However, I was running on a Windows system, so pytest was installed without all of its dependencies. When pluggy tries to load pytest plugins, which (I presume) depend again on pytest, pkg_resources notices this missing dependency and raises a DistributionNotFound error, which is silently eaten by pluggy.
For reference, here is the traceback that's being eaten (by adding a traceback.print_exc() inside pluggy):
Traceback (most recent call last):
File "c:\users\brenda\.virtualenvs\django-machina-_lipc3zt\lib\site-packages\pluggy\manager.py", line 254, in load_setuptools_entrypoints
plugin = ep.load()
File "c:\users\brenda\.virtualenvs\django-machina-_lipc3zt\lib\site-packages\pkg_resources\__init__.py", line 2320, in load
self.require(*args, **kwargs)
File "c:\users\brenda\.virtualenvs\django-machina-_lipc3zt\lib\site-packages\pkg_resources\__init__.py", line 2343, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "c:\users\brenda\.virtualenvs\django-machina-_lipc3zt\lib\site-packages\pkg_resources\__init__.py", line 777, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'colorama; sys_platform == "win32"' distribution was not found and is required by pytest
Why does pluggy eat this error? I traced the history back to the pytest repo and the change was introduced in this commit: pytest-dev/pytest@1bc444d5c8177cb7e1f2f8c14d8cd232aac54201, but that does not really tell me why it was introduced....
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pluggy/manager.py at the load_setuptools_entrypoints code around lines 254 and 266-267, then read the referenced pytest commit 1bc444d5c8177cb7e1f2f8c14d8cd232aac54201. Reproduce the missing-dependency traceback shown in the issue and determine the intended handling for DistributionNotFound; done should include a clear, user-visible outcome for this failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100