oduwsdl / ipwb

InterPlanetary Wayback: A distributed and persistent archive replay system using IPFS
MIT License
617 stars 39 forks source link

Add Python 3.12 to the test matrix #814

Closed machawk1 closed 1 month ago

machawk1 commented 1 year ago

Released October 2, 2023 though its availability in the GitHub Actions test suite is TBD.

machawk1 commented 1 year ago

Per the Python 3.12 release notes, pkg_resources is no longer installed by default in virtual environments in addition to the absence of distutils, setuptools, and easy_install (see https://github.com/python/cpython/issues/95299). ipwb uses this in testing, particular in test_backends.py. These can be installed via pip install setuptools once the venv has been activated.

machawk1 commented 1 year ago

The testing GH Action reports, "from six.moves.urllib_parse import urlsplit, urlunsplit" only for Python 3.12. six ought to be removed and its usage adapted to Python 3 built-in modules if possible, as ipwb no longer supports Python 2.

EDIT: see #816 for the above effort.

machawk1 commented 1 year ago

/Users/runner/work/ipwb/ipwb/ipwb/util.py:27: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

machawk1 commented 1 year ago

parse_version() within pkg_resources is the issue here. An alternative to obtain the package version is importlib.metadata import version but that does not split the version based on sortable keys, as did parse_version()

machawk1 commented 1 year ago

The main reason for this check was to send a communicate with the IPFS daemon differently if its version was < 0.4.10, which is far from supported by ipwb. Regardless, it is useful to have this logic to check for a supported version of the daemon to ensure commands from ipwb will be processed predictably.

machawk1 commented 1 year ago

An alternative can be had in the packaging external module.

from packaging.version import parse, Version
parse("1.1.1") < parse("1.2")
machawk1 commented 1 year ago

Another substitute from replay.py is the need for replacing:

index_file_name = pkg_resources.resource_filename(__name__, index_file_path)

with the equivalent from importlib.resources

machawk1 commented 1 month ago

We likely don't need to assert the function with assert in the name. That might be the solution to the testing reporting a comparison with None.