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
35
36
37
38
39
40
41
42
43
44
45
46
| from cx_Freeze import setup, Executable
# 定义额外需要包含的包
includes = [
"uvicorn",
"uvicorn.loops",
"uvicorn.loops.auto",
"uvicorn.protocols",
"uvicorn.protocols.http",
"uvicorn.lifespan",
"uvicorn.lifespan.on",
"uvicorn.lifespan.off",
"uvicorn.logging",
"fastapi",
"starlette",
"pydantic"
]
# 创建可执行文件的配置
executableApp = Executable(
script="main.py",
target_name="pyapp",
)
# 打包的参数配置
options = {
"build_exe": {
"build_exe": "./dist/",
"excludes": ["*.txt"],
"optimize": 2,
"includes": includes,
"packages": includes,
"zip_include_packages": "*",
"zip_exclude_packages": "",
}
}
setup(
name="pyapp",
version="1.0",
description="python app",
options=options,
executables=[executableApp]
)
|