jishaku icon indicating copy to clipboard operation
jishaku copied to clipboard

package_version function errors for Jishaku

Open fuh-Q opened this issue 3 years ago • 2 comments

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

  • Run the jsk root command OR
  • Import package_version from jishaku.modules and call it, passing "jishaku" as the first argument

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

  • [x] I have updated discord.py and jishaku to the latest available versions and have confirmed that this issue is still present
  • [x] I have searched the open issues for duplicates
  • [x] I have shown the entire traceback, if possible
  • [x] I have removed my token from display, if visible

System information

  • Jishaku v2.5.0
  • discord.py v2.0a

Screenshot

image

fuh-Q avatar May 06 '22 00:05 fuh-Q

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.

PythonCoderAS avatar May 12 '22 00:05 PythonCoderAS

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 avatar May 17 '23 01:05 scarletcafe