From 5a87c1c4b34fa4ce5b41ca5173b47bf4f739cc51 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 10 Nov 2024 14:52:55 +0100 Subject: [PATCH] Add libmagic for windows installations --- cps/dep_check.py | 20 +++++++++++++++----- requirements.txt | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cps/dep_check.py b/cps/dep_check.py index c80b0b29..0575aa56 100644 --- a/cps/dep_check.py +++ b/cps/dep_check.py @@ -39,17 +39,27 @@ def load_dependencies(optional=False): with open(req_path, 'r') as f: for line in f: if not line.startswith('#') and not line == '\n' and not line.startswith('git'): - res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?' - r'(?:;python_version([<=>\s]+)\'([\d\.]+)\')?', line.strip()) + res = re.match(r'(.*?)([<=>\s]+)([\d\.]+),?\s?([<=>\s]+)?([\d\.]+)?(?:\s?;\s?' + r'(?:(python_version)\s?([<=>]+)\s?\'([\d\.]+)\'|' + r'(sys_platform)\s?([\!=]+)\s?\'([\w]+)\'))?', line.strip()) try: if getattr(sys, 'frozen', False): dep_version = exe_deps[res.group(1).lower().replace('_', '-')] else: - if res.group(6) and res.group(7): - val = res.group(7).split(".") + if res.group(7) and res.group(8): + val = res.group(8).split(".") if not eval(str(sys.version_info[0]) + "." + "{:02d}".format(sys.version_info[1]) + - res.group(6) + val[0] + "." + "{:02d}".format(int(val[1]))): + res.group(7) + val[0] + "." + "{:02d}".format(int(val[1]))): continue + elif res.group(10) and res.group(11): + # only installed if platform is eqal, don't check if platform is not equal + if res.group(10) == "==": + if sys.platform != res.group(11): + continue + # installed if platform is not eqal, don't check if platform is equal + elif res.group(10) == "!=": + if sys.platform == res.group(11): + continue if importlib: dep_version = version(res.group(1)) else: diff --git a/requirements.txt b/requirements.txt index 2b4d136e..2c73c88f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,5 +21,6 @@ Flask-Limiter>=2.3.0,<3.9.0 regex>=2022.3.2,<2024.6.25 bleach>=6.0.0,<6.2.0 python-magic>=0.4.27,<0.5.0 +python-magic-bin>=0.4.0,<0.5.0;sys_platform=='win32' flask-httpAuth>=4.4.0,<5.0.0 cryptography>=30.0.0,<44.0.0