On Tue, Nov 19, 2024 at 4:18 PM Vincent Fazio <vfazio@xxxxxxxxxxx> wrote: > > > > > -----Original Message----- > > From: Bartosz Golaszewski <brgl@xxxxxxxx> > > Sent: Tuesday, November 19, 2024 8:43 AM > > To: Linus Walleij <linus.walleij@xxxxxxxxxx>; Kent Gibson > > <warthog618@xxxxxxxxx>; Vincent Fazio <vfazio@xxxxxxxxxxx> > > Cc: linux-gpio@xxxxxxxxxxxxxxx; Bartosz Golaszewski > > <bartosz.golaszewski@xxxxxxxxxx> > > Subject: [External] - [libgpiod][PATCH] bindings: python: tests: replace > > LooseVersion with packaging.version.Version > > > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > > > Distutils are deprecated. Use the Version class from packaging.version instead > > of LooseVersion from distutils.version. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > --- > > bindings/python/tests/__init__.py | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/bindings/python/tests/__init__.py > > b/bindings/python/tests/__init__.py > > index a0f22ae..d6275bb 100644 > > --- a/bindings/python/tests/__init__.py > > +++ b/bindings/python/tests/__init__.py > > @@ -2,10 +2,11 @@ > > # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@xxxxxxxx> > > > > import os > > -from distutils.version import LooseVersion > > > > -required_kernel_version = LooseVersion("5.19.0") -current_version = > > LooseVersion(os.uname().release.split("-")[0]) > > +from packaging.version import Version > > + > > +required_kernel_version = Version("5.19.0") current_version = > > +Version(os.uname().release.split("-")[0]) > > > > I think these changes are "accurate", however, the challenge is `packaging` > Is not part of the stdlib like distutils was so it's very possible someone runs into: > > vfazio4 /mnt/development/libgpiod/bindings/python # make python-tests-run > PYTHONPATH=/mnt/development/libgpiod/bindings/python \ > LD_LIBRARY_PATH=/mnt/development/libgpiod/lib/.libs/:\ > /mnt/development/libgpiod/tests/gpiosim/.libs/ \ > /mnt/development/libgpiod/bindings/python/venv/bin/python3 -B -m tests > Traceback (most recent call last): > File "/home/vfazio/.pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 188, in _run_module_as_main > mod_name, mod_spec, code = _get_module_details(mod_name, _Error) > File "/home/vfazio/.pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 147, in _get_module_details > return _get_module_details(pkg_main_name, error) > File "/home/vfazio/.pyenv/versions/3.9.8/lib/python3.9/runpy.py", line 111, in _get_module_details > __import__(pkg_name) > File "/mnt/development/libgpiod/bindings/python/tests/__init__.py", line 6, in <module> > from packaging.version import Version > ModuleNotFoundError: No module named 'packaging' > make: *** [Makefile:691: python-tests-run] Error 1 > > It may be necessary to document that anyone doing development on the bindings prepares a virtual environment with a minimal set of required dependencies and that it's activated when the build is configured... or the tests need to setup an environment with proper dependencies necessary for them to run. > > We do have it as a requirement in pyproject.toml though, shouldn't that be enough? Bart