Expand file tree Collapse file tree 4 files changed +25
-40
lines changed Original file line number Diff line number Diff line change
1
+ include gpt_server/script/*.yaml
Original file line number Diff line number Diff line change 1
- import argparse
2
1
import subprocess
3
2
import os
3
+ import typer
4
4
5
+ app = typer .Typer ()
5
6
root_dir = os .path .dirname (__file__ )
6
7
root_dir = os .path .abspath (root_dir )
7
8
chat_ui_path = os .path .join (root_dir , "serving" , "chat_ui.py" )
8
9
server_ui_path = os .path .join (root_dir , "serving" , "server_ui.py" )
9
10
10
11
11
- def run ():
12
- parser = argparse .ArgumentParser (description = "GPT Server CLI" )
13
- parser .add_argument ("--chat_ui" , action = "store_true" , help = "启动问答UI界面" )
14
- parser .add_argument ("--server_ui" , action = "store_true" , help = "启动服务UI界面" )
15
- args = parser .parse_args ()
16
- print (args )
17
- if args .chat_ui :
18
- cmd = f"streamlit run { chat_ui_path } "
19
- subprocess .run (cmd , shell = True )
20
- if args .server_ui :
12
+ @app .command (help = "启动 GPT Server UI" )
13
+ def ui (
14
+ server : bool = typer .Option (False , help = "启动服务UI界面" ),
15
+ chat : bool = typer .Option (False , help = "启动问答UI界面" ),
16
+ ):
17
+ if server :
21
18
cmd = f"streamlit run { server_ui_path } "
22
19
subprocess .run (cmd , shell = True )
20
+ if chat :
21
+ cmd = f"streamlit run { chat_ui_path } "
22
+ subprocess .run (cmd , shell = True )
23
+
24
+
25
+ def main ():
26
+ app ()
23
27
24
28
25
29
if __name__ == "__main__" :
26
- run ()
30
+ main ()
Original file line number Diff line number Diff line change @@ -24,5 +24,10 @@ dependencies = [
24
24
" vllm==0.6.3" ,
25
25
]
26
26
27
+
27
28
[project .scripts ]
28
- gpt_server = " gpt_server.cli:run"
29
+ gpt_server = " gpt_server.cli:main"
30
+
31
+ [build-system ]
32
+ requires = [" setuptools" , " wheel" ]
33
+ build-backend = " setuptools.build_meta"
Original file line number Diff line number Diff line change 1
1
import os
2
- import sys
3
- import subprocess
4
2
from setuptools import setup , find_packages
5
3
from setuptools .command .install import install
6
4
9
7
version_file = "gpt_server/version.py"
10
8
11
9
12
- # 自定义安装类
13
- class CustomInstallCommand (install ):
14
- """自定义安装命令类,用于在安装过程中执行额外的脚本"""
15
-
16
- def run (self ):
17
- # 调用父类的 run 方法
18
- install .run (self )
19
-
20
- # 运行 Bash 脚本
21
- script_path = os .path .join (os .path .dirname (__file__ ), "install.sh" )
22
- if os .path .exists (script_path ):
23
- print ("Running install_script.sh..." )
24
- try :
25
- subprocess .check_call (["/bin/bash" , script_path ])
26
- except subprocess .CalledProcessError as e :
27
- print (f"Error executing script { script_path } : { e } " )
28
- sys .exit (1 )
29
- else :
30
- print (f"Script { script_path } not found!" )
31
-
32
-
33
10
def readme ():
34
11
with open (os .path .join (pwd , "README.md" ), encoding = "utf-8" ) as f :
35
12
content = f .read ()
@@ -51,9 +28,7 @@ def get_version():
51
28
long_description_content_type = "text/markdown" ,
52
29
author = "Yu Liu" ,
53
30
author_email = "506610466@qq.com" ,
54
- packages = find_packages (exclude = ()),
31
+ packages = find_packages (),
32
+ include_package_data = True , # 确保包含 MANIFEST.in 中的文件
55
33
# ... 其他 setup 参数 ...
56
- cmdclass = {
57
- "install" : CustomInstallCommand , # 关联自定义安装类
58
- },
59
34
)
0 commit comments