From 35648d3d2f4a224d565dfa2b1bf4554ae18b81c0 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Mon, 1 Aug 2022 15:13:51 +0800 Subject: [PATCH] feat: python pre-compile --- Basis/Compile.py | 11 +++++++++++ Dockerfile | 1 + docker/compile.py | 10 ---------- 3 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 Basis/Compile.py delete mode 100644 docker/compile.py diff --git a/Basis/Compile.py b/Basis/Compile.py new file mode 100644 index 0000000..e0e5f7f --- /dev/null +++ b/Basis/Compile.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import compileall +from Basis.Logger import logging + + +def startCompile(dirRange: str = '/'): + for optimize in [-1, 1, 2]: + logging.warning('start compile -> %s (optimize = %i)' %(dirRange, optimize)) + compileall.compile_dir(dirRange, quiet = 1, maxlevels = 256, optimize = optimize) diff --git a/Dockerfile b/Dockerfile index e89b548..b66a330 100644 --- a/Dockerfile +++ b/Dockerfile @@ -479,5 +479,6 @@ RUN \ apk add --no-cache boost-program_options c-ares \ ca-certificates glib libev libsodium libstdc++ mbedtls pcre redis && \ pip3 --no-cache-dir install colorlog flask IPy pysocks redis requests && \ + rm -rf $(find / -name '__pycache__') && \ echo "daemonize yes" >> /etc/redis.conf COPY --from=asset /asset / diff --git a/docker/compile.py b/docker/compile.py deleted file mode 100644 index 5751689..0000000 --- a/docker/compile.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python -# -*- coding:utf-8 -*- - -import compileall - -maxLevels = 256 -compileDir = '/usr' -compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels) -compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels, optimize = 1) -compileall.compile_dir(compileDir, quiet = 1, maxlevels = maxLevels, optimize = 2)