正在显示
1 个修改的文件
包含
35 行增加
和
0 行删除
compile.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2022/2/28 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +import py_compile | |
7 | +import os | |
8 | +import shutil | |
9 | + | |
10 | +def compile(des): | |
11 | + | |
12 | + if os.path.exists(des): | |
13 | + os.system("rd/s/q {}".format(des)) | |
14 | + shutil.rmtree(des, True) | |
15 | + project_dir = os.path.dirname(os.path.realpath(__file__)) | |
16 | + | |
17 | + shutil.copytree(project_dir, des) | |
18 | + git_path = os.path.join(des,".git") | |
19 | + if os.path.exists(os.path.join(des,".git")): | |
20 | + os.system("rd/s/q {}".format(git_path)) | |
21 | + | |
22 | + for root, dirs, files in os.walk(os.path.join(des,"app")): | |
23 | + for fn in files: | |
24 | + if fn.endswith("py"): | |
25 | + py_file = os.path.join(root, fn) | |
26 | + py_compile.compile(py_file) | |
27 | + os.remove(py_file) | |
28 | + pyc_file = os.path.join(root, "__pycache__",fn.split(".")[0]+".cpython-37.pyc") | |
29 | + des_pyc_file = os.path.join(root,fn.split(".")[0]+".pyc") | |
30 | + shutil.copy(pyc_file,des_pyc_file) | |
31 | + | |
32 | +if __name__ == '__main__': | |
33 | + des="F:\Python\DMapManagerPublish" | |
34 | + compile(des) | |
35 | + | ... | ... |
请
注册
或
登录
后发表评论