Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 1 | From 96e8f0b2d13e890d9ffff8673f18dcc94290efb2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Tim Orling <tim.orling@konsulko.com> |
| 3 | Date: Thu, 13 Jan 2022 20:06:33 -0600 |
| 4 | Subject: [PATCH] setup.py: StrictVersion -> packaging.version.* |
| 5 | |
| 6 | distutils is deprecated in Python 3.10 and will be removed in Python |
| 7 | 3.12 [1] |
| 8 | |
| 9 | The recommended replacement for distutils.version is to use |
| 10 | packaging.version |
| 11 | |
| 12 | StrictVersion can be replaced by packaging.version.Version and helpers |
| 13 | like packaging.version.parse() |
| 14 | |
| 15 | [1] https://www.python.org/dev/peps/pep-0632/ |
| 16 | [2] https://packaging.pypa.io/en/latest/version.html |
| 17 | |
| 18 | Upstream-Status: Submitted [https://github.com/gammu/python-gammu/pull/67] |
| 19 | |
| 20 | Signed-off-by: Tim Orling <tim.orling@konsulko.com> |
| 21 | --- |
| 22 | setup.py | 6 +++--- |
| 23 | 1 file changed, 3 insertions(+), 3 deletions(-) |
| 24 | |
| 25 | diff --git a/setup.py b/setup.py |
| 26 | index a458181..bffb09d 100755 |
| 27 | --- a/setup.py |
| 28 | +++ b/setup.py |
| 29 | @@ -30,7 +30,7 @@ import os |
| 30 | import platform |
| 31 | import subprocess |
| 32 | import sys |
| 33 | -from distutils.version import StrictVersion |
| 34 | +from packaging.version import parse, Version |
| 35 | |
| 36 | from setuptools import Extension, setup |
| 37 | |
| 38 | @@ -112,9 +112,9 @@ class GammuConfig: |
| 39 | with open(self.config_path(self.path)) as handle: |
| 40 | for line in handle: |
| 41 | if line.startswith("#define GAMMU_VERSION "): |
| 42 | - version = line.split('"')[1] |
| 43 | + version = parse(line.split('"')[1]) |
| 44 | |
| 45 | - if version is None or StrictVersion(version) < StrictVersion(GAMMU_REQUIRED): |
| 46 | + if version is None or version < parse(GAMMU_REQUIRED): |
| 47 | print("Too old Gammu version, please upgrade!") |
| 48 | sys.exit(100) |
| 49 | |