Skip to content

Commit d9edcb4

Browse files
committed
feat: 🎸 replace pyminifier using python-minifier
Closes: #28
1 parent 9e985ed commit d9edcb4

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

pyencrypt/encrypt.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import os
22
import re
3-
import subprocess
43
from pathlib import Path
54

5+
import python_minifier
6+
67
from pyencrypt.aes import aes_encrypt
78
from pyencrypt.generate import generate_rsa_number
89
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
7374
loader_file_path.touch(exist_ok=True)
7475

7576
decrypt_source = '\n'.join(decrypt_source_ls)
76-
loader_file_path.write_text(f"{decrypt_source}\n{loader_source}")
7777

7878
# Origin file
7979
loader_origin_file_path = temp_dir / 'loader_origin.py'
8080
loader_origin_file_path.touch(exist_ok=True)
8181
loader_origin_file_path.write_text(f"{decrypt_source}\n{loader_source}")
8282

83-
args = [
84-
'pyminifier',
85-
'--obfuscate-classes',
86-
'--obfuscate-import-methods',
87-
'--replacement-length',
88-
'20',
89-
'-o',
90-
loader_file_path.as_posix(),
91-
loader_file_path.as_posix(),
92-
]
93-
ret = subprocess.run(args, shell=False, encoding='utf-8')
94-
if ret.returncode == 0:
95-
pass
96-
97-
from setuptools import setup
83+
loader_file_path.write_text(
84+
python_minifier.minify(loader_origin_file_path.read_text())
85+
)
86+
87+
from setuptools import setup # isort:skip
9888
from Cython.Build import cythonize
9989
from Cython.Distutils import build_ext
10090
setup(

requirement.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
click==8.0.3
22
Cython==0.29.24
33
pycryptodome==3.14.1
4-
pyminifier==2.1
4+
python-minifier==2.9.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ keywords = python-encrypt, import-hook
3131
install_requires =
3232
Cython >= 0.29.24
3333
pycryptodome >= 3.14.1
34-
pyminifier >= 2.1
34+
python-minifier >= 2.6.0
3535
click
3636
python_requires = >=3.6
3737
packages = find:

0 commit comments

Comments
 (0)