scarletcafe / jishaku

A debugging and testing cog for discord.py rewrite bots.
https://jishaku.readthedocs.io/en/latest/
MIT License
541 stars 181 forks source link

package_version function errors for Jishaku #172

Closed fuh-Q closed 6 days ago

fuh-Q commented 2 years ago

Summary

My jsk command keeps erroring when I run the root command, and it seems to be a problem with the package_version function used to determine Jishaku's version as well as discord.py's version

Reproduction steps

Expected results

Return Jishaku's version (in my case 2.5.0)

Actual results

Kept giving me this error in the console

Traceback (most recent call last):
  File "/home/user/bot/cogs/Eval.py", line 445, in _eval
    ret = await func()
  File "<string>", line 6, in func
  File "/home/user/.local/lib/python3.10/site-packages/jishaku/modules.py", line 96, in package_version
    return pkg_resources.get_distribution(package_name).version
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 482, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 358, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 792, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (importlib-metadata 1.5.0 (/usr/lib/python3/dist-packages), Requirement.parse('importlib-metadata>=3.7.0; python_version < "3.10"'), {'jishaku'})

Checklist

System information

Screenshot

image

PythonCoderAS commented 2 years ago

This is not a jishaku bug. I just tested this by spinning up a fresh venv and testing it. What it seems to be is that your package manager (apt maybe) installed an incompatible version of a dependency, and python/pip cannot solve this because the package manager forbids pip from uninstalling packages installed by it. This is why you always use venvs for anything other than non-global cli tools.

scarletcafe commented 1 year ago

pkg_resources related problems are also the cause of #205. Will need to purposefully break one of my environments to reproduce it enough to fix it, but the goal is probably to either move from pkg_resources to importlib_metadata (if possible), or to engineer a solution that does not depend on pip's whims at all.

scarletcafe commented 6 days ago

pkg_resources usage was replaced in #213. I'm going to assume that this fixes this issue. If it occurs again just reopen.