1
0
mirror of https://github.com/janeczku/calibre-web.git synced 2024-11-21 17:56:35 +02:00

Improved dep check for windows exe version and further fixes for windows exe

This commit is contained in:
Ozzie Fernandez Isaacs 2024-11-18 18:00:19 +01:00
parent f9cfb38ad3
commit 92fbc9c792
5 changed files with 22 additions and 23 deletions

2
cps.py
View File

@ -43,7 +43,7 @@ def hide_console_windows():
if __name__ == '__main__':
if os.name == "nt":
hide_console_windows()
pass # hide_console_windows()
main()

View File

@ -23,7 +23,7 @@
import sys
import platform
import sqlite3
import importlib
from importlib.metadata import metadata
from collections import OrderedDict
import flask
@ -41,7 +41,7 @@ req = dep_check.load_dependencies(False)
opt = dep_check.load_dependencies(True)
for i in (req + opt):
modules[i[1]] = i[0]
modules['Jinja2'] = importlib.metadata.version("jinja2")
modules['Jinja2'] = metadata("jinja2")["Version"]
if sys.version_info < (3, 12):
modules['pySqlite'] = sqlite3.version
modules['SQLite'] = sqlite3.sqlite_version

View File

@ -23,11 +23,10 @@ import zipfile
import json
from io import BytesIO
from flask_babel.speaklater import LazyString
from importlib.metadata import metadata
import os
from flask import send_file
import importlib
from . import logger, config
from .about import collect_stats
@ -50,7 +49,7 @@ def assemble_logfiles(file_name):
with open(f, 'rb') as fd:
shutil.copyfileobj(fd, wfd)
wfd.seek(0)
version = importlib.metadata.version("flask")
version = metadata("flask")["Version"]
if int(version.split('.')[0]) < 2:
return send_file(wfd,
as_attachment=True,
@ -74,7 +73,7 @@ def send_debug():
for fp in file_list:
zf.write(fp, os.path.basename(fp))
memory_zip.seek(0)
version = importlib.metadata.version("flask")
version = metadata("flask")["Version"]
if int(version.split('.')[0]) < 2:
return send_file(memory_zip,
as_attachment=True,

View File

@ -43,23 +43,23 @@ def load_dependencies(optional=False):
r'(?:(python_version)\s?([<=>]+)\s?\'([\d\.]+)\'|'
r'(sys_platform)\s?([\!=]+)\s?\'([\w]+)\'))?', line.strip())
try:
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(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 getattr(sys, 'frozen', False):
dep_version = exe_deps[res.group(1).lower().replace('_', '-')]
else:
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(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:

View File

@ -23,7 +23,7 @@ import json
import mimetypes
import chardet # dependency of requests
import copy
import importlib
from importlib.metadata import metadata
from flask import Blueprint, jsonify
from flask import request, redirect, send_from_directory, make_response, flash, abort, url_for, Response
@ -86,7 +86,7 @@ except ImportError:
sort = sorted # Just use regular sort then, may cause issues with badly named pages in cbz/cbr files
sql_version = importlib.metadata.version("sqlalchemy")
sql_version = metadata("sqlalchemy")["Version"]
sqlalchemy_version2 = ([int(x) for x in sql_version.split('.')] >= [2, 0, 0])