Remove use of distutils

As of Python 3.12 setuptools is no longer installed by default and
if setuptools is not installed distutils is not found and SafeEyes
fails to start.

Furthermore distutils is deprecated and should thus not be used
anymore. The packaging module provides a replacement for LooseVersion
and it is also recommended by PEP 632 [1].

Also update required Python version for Debian to 3.12 or newer.

[1] https://peps.python.org/pep-0632/#migration-advice
This commit is contained in:
Tero Paloheimo 2023-12-30 19:42:32 +02:00
parent a156cea515
commit 5c0884facb
4 changed files with 9 additions and 7 deletions

6
debian/control vendored
View File

@ -2,14 +2,14 @@ Source: safeeyes
Section: utils
Priority: optional
Maintainer: Gobinath Loganathan <slgobinath@gmail.com>
Build-Depends: debhelper (>= 10), dh-python, python3, python3-setuptools
Build-Depends: debhelper (>= 10), dh-python, python3, python3-packaging
Standards-Version: 3.9.6
X-Python3-Version: >= 3.5
X-Python3-Version: >= 3.12
Homepage: https://github.com/slgobinath/SafeEyes/
Package: safeeyes
Architecture: all
Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-ayatanaappindicator3-0.1, python3 (>= 3.5.0), python3-xlib, python3-dbus, gir1.2-notify-0.7, python3-babel, x11-utils, xprintidle, alsa-utils, python3-psutil, python3-croniter
Depends: ${misc:Depends}, ${python3:Depends}, gir1.2-ayatanaappindicator3-0.1, python3 (>= 3.12.0), python3-xlib, python3-dbus, gir1.2-notify-0.7, python3-babel, x11-utils, xprintidle, alsa-utils, python3-psutil, python3-croniter
Description: Safe Eyes
Safe Eyes is a simple tool to remind you to take periodic breaks for your eyes. This is essential for anyone spending more time on the computer to avoid eye strain and other physical problems.
.

View File

@ -22,9 +22,10 @@ This module contains the entity classes used by Safe Eyes and its plugins.
import logging
import random
from distutils.version import LooseVersion
from enum import Enum
from packaging.version import parse
from safeeyes import utility
@ -323,7 +324,7 @@ class Config:
else:
user_config_version = str(
meta_obj.get('config_version', '0.0.0'))
if LooseVersion(user_config_version) != LooseVersion(system_config_version):
if parse(user_config_version) != parse(system_config_version):
# Update the user config
self.__merge_dictionary(
self.__user_config, self.__system_config)

View File

@ -32,7 +32,6 @@ import sys
import shutil
import subprocess
import threading
from distutils.version import LooseVersion
from logging.handlers import RotatingFileHandler
from pathlib import Path
@ -43,6 +42,7 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import GdkPixbuf
from packaging.version import parse
gi.require_version('Gdk', '3.0')
@ -547,7 +547,7 @@ def __update_plugin_config(plugin, plugin_config, config):
if plugin_config is None:
config['plugins'].remove(plugin)
else:
if LooseVersion(plugin.get('version', '0.0.0')) != LooseVersion(plugin_config['meta']['version']):
if parse(plugin.get('version', '0.0.0')) != parse(plugin_config['meta']['version']):
# Update the configuration
plugin['version'] = plugin_config['meta']['version']
setting_ids = []

View File

@ -8,6 +8,7 @@ requires = [
'psutil',
'croniter',
'PyGObject',
'packaging',
'python-xlib'
]