jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.35k stars 154 forks source link

No support for python >= 3.8 #217

Closed miquelmassot closed 1 year ago

miquelmassot commented 1 year ago

The line https://github.com/jazzband/prettytable/blob/3.5.0/pyproject.toml#L17 prevents everyone from using your package with python >= 3.8.

miquelmassot commented 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
hugovk commented 1 year ago

Please can you give some more information?

What did you do?

What did you expect to happen?

What actually happened?

What versions are you using?

Please include code that reproduces the issue.

The best reproductions are self-contained scripts with minimal dependencies.

# code goes here
miquelmassot commented 1 year ago

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

hugovk commented 1 year ago

Python 3.7-3.11 are supported, as documented here:

https://github.com/jazzband/prettytable/blob/aa4e316c96f0fe749281eb40c5489e59ba2cc054/pyproject.toml#L15

https://github.com/jazzband/prettytable/blob/aa4e316c96f0fe749281eb40c5489e59ba2cc054/pyproject.toml#L26-L32

(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?

hugovk commented 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

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.

hugovk commented 1 year ago

Closing due to lack of response, looks like the bug was fixed in https://github.com/ocean-perception/oplab_pipeline/commit/f97f3724cbfc30a69af163c769aad8afa2d742b6.