Skip to content

Commit

Permalink
Remove use of distutils
Browse files Browse the repository at this point in the history
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].

[1] https://peps.python.org/pep-0632/#migration-advice
  • Loading branch information
terop committed Jun 26, 2024
1 parent a156cea commit 1844649
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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, python3-setuptools
Standards-Version: 3.9.6
X-Python3-Version: >= 3.5
Homepage: https://github.com/slgobinath/SafeEyes/
Expand Down
5 changes: 3 additions & 2 deletions safeeyes/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

import logging
import random
from distutils.version import LooseVersion
from enum import Enum

from packaging.version import parse

from safeeyes import utility


Expand Down Expand Up @@ -323,7 +324,7 @@ def __init__(self, init=True):
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)
Expand Down
4 changes: 2 additions & 2 deletions safeeyes/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import shutil
import subprocess
import threading
from distutils.version import LooseVersion
from logging.handlers import RotatingFileHandler
from pathlib import Path

Expand All @@ -43,6 +42,7 @@
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')

Expand Down Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'psutil',
'croniter',
'PyGObject',
'packaging',
'python-xlib'
]

Expand Down

0 comments on commit 1844649

Please sign in to comment.