@@ -78,7 +78,6 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Path = None):
7878 loader_origin_file_path .touch (exist_ok = True )
7979 loader_origin_file_path .write_text (f"{ decrypt_source } \n { loader_source } " )
8080
81- setup_file_path = Path (os .path .abspath (__file__ )).parent / 'setup.py'
8281 args = [
8382 'pyminifier' , '--obfuscate-classes' , '--obfuscate-import-methods' ,
8483 '--replacement-length' , '20' , '-o' ,
@@ -89,17 +88,15 @@ def generate_so_file(cipher_key: str, d: int, n: int, base_dir: Path = None):
8988 if ret .returncode == 0 :
9089 pass
9190
92- args = [
93- 'python' ,
94- setup_file_path .as_posix (), 'build_ext' , '--build-lib' ,
95- temp_dir .as_posix ()
96- ]
97- ret = subprocess .run (args ,
98- shell = False ,
99- stderr = subprocess .PIPE ,
100- encoding = 'utf-8' )
101- if ret .returncode == 0 :
102- pass
91+ from setuptools import setup
92+ from Cython .Build import cythonize
93+ from Cython .Distutils import build_ext
94+ setup (
95+ ext_modules = cythonize (loader_file_path .as_posix (), language_level = "3" ),
96+ script_args = ['build_ext' , '--build-lib' , temp_dir .as_posix ()],
97+ cmdclass = {'build_ext' : build_ext },
98+ )
99+
103100 return True
104101
105102
0 commit comments