Changeset - a5d15a7511a9
[Not reviewed]
stable
0 2 0
Mads Kiilerich (mads) - 20 months ago 2024-07-19 23:19:34
mads@kiilerich.com
Grafted from: da382b9e9631
lib: use packaging.version.Version instead of dropped distutils.version.StrictVersion

distutils is dropped in Python 3.12 . Migrate to packaging as described on
https://github.com/pypa/packaging/issues/520 .
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/utils2.py
Show inline comments
 
@@ -35,16 +35,16 @@ import logging
 
import os
 
import re
 
import string
 
import sys
 
import time
 
import urllib.parse
 
from distutils.version import StrictVersion
 

	
 
import bcrypt
 
import urlobject
 
from packaging.version import Version
 
from sqlalchemy.engine import url as sa_url
 
from sqlalchemy.exc import ArgumentError
 
from tg import tmpl_context
 
from tg.support.converters import asbool, aslist
 
from webhelpers2.text import collapse, remove_formatting, strip_tags
 

	
 
@@ -491,13 +491,13 @@ def check_password(password, hashed):
 
        log.error('error from bcrypt checking password: %s', e)
 
        return False
 
    log.error('check_password failed - no method found for hash length %s', len(hashed))
 
    return False
 

	
 

	
 
git_req_ver = StrictVersion('1.7.4')
 
git_req_ver = Version('1.7.4')
 

	
 
def check_git_version():
 
    """
 
    Checks what version of git is installed on the system, and raise a system exit
 
    if it's too old for Kallithea to work properly.
 
    """
 
@@ -522,24 +522,24 @@ def check_git_version():
 
        log.warning('No working git executable found - check "git_path" in the ini file.')
 
        return None
 

	
 
    output = safe_str(stdout).strip()
 
    m = re.search(r"\d+.\d+.\d+", output)
 
    if m:
 
        ver = StrictVersion(m.group(0))
 
        ver = Version(m.group(0))
 
        log.debug('Git executable: "%s", version %s (parsed from: "%s")',
 
                  settings.GIT_EXECUTABLE_PATH, ver, output)
 
        if ver < git_req_ver:
 
            log.error('Kallithea detected %s version %s, which is too old '
 
                      'for the system to function properly. '
 
                      'Please upgrade to version %s or later. '
 
                      'If you strictly need Mercurial repositories, you can '
 
                      'clear the "git_path" setting in the ini file.',
 
                      settings.GIT_EXECUTABLE_PATH, ver, git_req_ver)
 
            log.error("Terminating ...")
 
            sys.exit(1)
 
    else:
 
        ver = StrictVersion('0.0.0')
 
        ver = Version('0.0.0')
 
        log.warning('Error finding version number in "%s --version" stdout:\n%s',
 
                    settings.GIT_EXECUTABLE_PATH, output)
 

	
 
    return ver
scripts/deps.py
Show inline comments
 
@@ -125,12 +125,13 @@ pygments
 
dulwich
 
beaker
 
psycopg2
 
docs
 
setup
 
conftest
 
packaging
 
'''.split())
 

	
 
normal_modules = set('''
 
kallithea
 
kallithea.controllers.base
 
kallithea.lib
0 comments (0 inline, 0 general)