Add Python 3.12 and fix Radarr handling (#1989)

* Added Python3.12 and future 3.13

* Fix Radarr result handling

* remove py2.7 and py3.7 support
This commit is contained in:
Clinton Hall 2024-02-28 15:47:04 +13:00 committed by GitHub
commit f98d6fff65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
173 changed files with 17498 additions and 21001 deletions

View file

@ -1,28 +1,25 @@
import sys
import marshal
import contextlib
from distutils.version import StrictVersion
from .py33compat import Bytecode
from .py27compat import find_module, PY_COMPILED, PY_FROZEN, PY_SOURCE
from . import py27compat
import dis
__all__ = [
'Require', 'find_module', 'get_module_constant', 'extract_constant'
]
from . import _imp
from ._imp import find_module, PY_COMPILED, PY_FROZEN, PY_SOURCE
from .extern.packaging.version import Version
__all__ = ['Require', 'find_module', 'get_module_constant', 'extract_constant']
class Require:
"""A prerequisite to building or installing a distribution"""
def __init__(
self, name, requested_version, module, homepage='',
attribute=None, format=None):
self, name, requested_version, module, homepage='', attribute=None, format=None
):
if format is None and requested_version is not None:
format = StrictVersion
format = Version
if format is not None:
requested_version = format(requested_version)
@ -40,8 +37,12 @@ class Require:
def version_ok(self, version):
"""Is 'version' sufficiently up-to-date?"""
return self.attribute is None or self.format is None or \
str(version) != "unknown" and version >= self.requested_version
return (
self.attribute is None
or self.format is None
or str(version) != "unknown"
and self.format(version) >= self.requested_version
)
def get_version(self, paths=None, default="unknown"):
"""Get version number of installed module, 'None', or 'default'
@ -79,7 +80,7 @@ class Require:
version = self.get_version(paths)
if version is None:
return False
return self.version_ok(version)
return self.version_ok(str(version))
def maybe_close(f):
@ -87,6 +88,7 @@ def maybe_close(f):
def empty():
yield
return
if not f:
return empty()
@ -111,12 +113,12 @@ def get_module_constant(module, symbol, default=-1, paths=None):
f.read(8) # skip magic & date
code = marshal.load(f)
elif kind == PY_FROZEN:
code = py27compat.get_frozen_object(module, paths)
code = _imp.get_frozen_object(module, paths)
elif kind == PY_SOURCE:
code = compile(f.read(), path, 'exec')
else:
# Not something we can parse; we'll have to import it. :(
imported = py27compat.get_module(module, paths, info)
imported = _imp.get_module(module, paths, info)
return getattr(imported, symbol, None)
return extract_constant(code, symbol, default)
@ -140,13 +142,13 @@ def extract_constant(code, symbol, default=-1):
name_idx = list(code.co_names).index(symbol)
STORE_NAME = 90
STORE_GLOBAL = 97
LOAD_CONST = 100
STORE_NAME = dis.opmap['STORE_NAME']
STORE_GLOBAL = dis.opmap['STORE_GLOBAL']
LOAD_CONST = dis.opmap['LOAD_CONST']
const = default
for byte_code in Bytecode(code):
for byte_code in dis.Bytecode(code):
op = byte_code.opcode
arg = byte_code.arg
@ -157,6 +159,8 @@ def extract_constant(code, symbol, default=-1):
else:
const = default
return None
def _update_globals():
"""