forked from LCF2764/Encrypt-python-code-License-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
34 lines (29 loc) · 883 Bytes
/
setup.py
File metadata and controls
34 lines (29 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# coding:utf-8
from distutils.core import setup
from Cython.Build import cythonize
import os
'''
该文件的执行需要的在Terminal中输入 python setup.py build_ext --inplace
使用Cpython 编译python文件,关键函数编译成pyd文件(相当于dll)
'''
# 在列表中输入需要加密的py文件
key_funs = ['get_time.py']
setup(
name="XX app",
ext_modules = cythonize(key_funs),
)
'''
1、将编译后的pyd文件的命名更改成与原py文件一致
2、删除编译后得到的c文件和原py文件
'''
print("——————", os.getcwd(), "——————")
files = os.listdir(os.getcwd())
print(files)
for fi in files:
if fi.__contains__(".pyd"):
re_name = fi.split(".")[0] + ".pyd"
print(re_name)
os.rename(fi, re_name)
elif fi.__contains__(".c") or fi in key_funs:
os.remove(fi)
print('Done!')