Closed miquelmassot closed 1 year ago
Bottom cut of a traceback when running code with v3.5.0:
File "/usr/local/lib/python3.10/site-packages/oplab/console.py", line 199, in get_version
return str(pkg_resources.require(pkg_name)[0].version)
File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'importlib-metadata; python_version < "3.8"' distribution was not found and is required by prettytable
Please can you give some more information?
Please include code that reproduces the issue.
The best reproductions are self-contained scripts with minimal dependencies.
# code goes here
Solved with an upgrade of setuptools. However, it's worth mentioning that the python versions you support do not match with what is written in your pyproject.toml
Python 3.7-3.11 are supported, as documented here:
(And 3.12 now also tested: https://github.com/jazzband/prettytable/pull/221)
Setuptools is no longer used, we've switched to Hatchling (https://github.com/jazzband/prettytable/pull/212).
What version of setuptools did you have before? What do you have now?
Can you share the full traceback?
Bottom cut of a traceback when running code with v3.5.0:
File "/usr/local/lib/python3.10/site-packages/oplab/console.py", line 199, in get_version return str(pkg_resources.require(pkg_name)[0].version) File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 900, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 786, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'importlib-metadata; python_version < "3.8"' distribution was not found and is required by prettytable
The exception is coming from oplab/console.py
, not PrettyTable:
File "/usr/local/lib/python3.10/site-packages/oplab/console.py", line 199, in get_version return str(pkg_resources.require(pkg_name)[0].version)
Digging that up:
https://github.com/ocean-perception/oplab_pipeline/blob/master/src/oplab/console.py#L185-L199
@staticmethod
def get_version(pkg_name="oplab_pipeline"):
"""Returns pkg_name version number
Parameters
----------
pkg_name : str
Name of the python package, by default 'oplab_pipeline'
Returns
-------
str
version number (e.g. "0.1.2")
"""
return str(pkg_resources.require(pkg_name)[0].version)
That's calling pkg_resources
, which is part of setuptools. You should probably report it to https://github.com/ocean-perception/oplab_pipeline to make sure they have all their dependencies sorted, and explicitly depend on setuptools rather than hoping it's in the environment.
And pkg_resources is pretty slow, they may also want to replace that dependency with the faster importlib.metadata. For example, see https://github.com/pylast/pylast/pull/377 and https://github.com/jazzband/prettytable/pull/96.
Closing due to lack of response, looks like the bug was fixed in https://github.com/ocean-perception/oplab_pipeline/commit/f97f3724cbfc30a69af163c769aad8afa2d742b6.
The line https://github.com/jazzband/prettytable/blob/3.5.0/pyproject.toml#L17 prevents everyone from using your package with python >= 3.8.