From 4d6711d3e4b7768e49506d669a2f3ed010d1ef91 Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Thu, 14 Dec 2023 11:38:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20replace=20pyminifier=20u?= =?UTF-8?q?sing=20python-minifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #28 --- pyencrypt/encrypt.py | 24 +++++++----------------- requirement.txt | 2 +- setup.cfg | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pyencrypt/encrypt.py b/pyencrypt/encrypt.py index 6a4a904..954b3d1 100644 --- a/pyencrypt/encrypt.py +++ b/pyencrypt/encrypt.py @@ -1,8 +1,9 @@ import os import re -import subprocess from pathlib import Path +import python_minifier + from pyencrypt.aes import aes_encrypt from pyencrypt.generate import generate_rsa_number from pyencrypt.ntt import ntt @@ -73,28 +74,17 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Path = None, lic loader_file_path.touch(exist_ok=True) decrypt_source = '\n'.join(decrypt_source_ls) - loader_file_path.write_text(f"{decrypt_source}\n{loader_source}") # Origin file loader_origin_file_path = temp_dir / 'loader_origin.py' loader_origin_file_path.touch(exist_ok=True) loader_origin_file_path.write_text(f"{decrypt_source}\n{loader_source}") - args = [ - 'pyminifier', - '--obfuscate-classes', - '--obfuscate-import-methods', - '--replacement-length', - '20', - '-o', - loader_file_path.as_posix(), - loader_file_path.as_posix(), - ] - ret = subprocess.run(args, shell=False, encoding='utf-8') - if ret.returncode == 0: - pass - - from setuptools import setup + loader_file_path.write_text( + python_minifier.minify(loader_origin_file_path.read_text()) + ) + + from setuptools import setup # isort:skip from Cython.Build import cythonize from Cython.Distutils import build_ext setup( diff --git a/requirement.txt b/requirement.txt index ced629c..112162c 100644 --- a/requirement.txt +++ b/requirement.txt @@ -1,4 +1,4 @@ click==8.0.3 Cython==0.29.24 pycryptodome==3.14.1 -pyminifier==2.1 +python-minifier==2.9.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 16877d3..7db65bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ keywords = python-encrypt, import-hook install_requires = Cython >= 0.29.24 pycryptodome >= 3.14.1 - pyminifier >= 2.1 + python-minifier >= 2.6.0 click python_requires = >=3.6 packages = find: