Skip to content

Commit f8361f7

Browse files
committed
add setup
1 parent 0c378d8 commit f8361f7

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

gpt_server/model_worker/base/__init__.py

Whitespace-only changes.

gpt_server/openai_api_protocol/__init__.py

Whitespace-only changes.

gpt_server/serving/__init__.py

Whitespace-only changes.

gpt_server/version.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from typing import Tuple
2+
3+
__version__ = "0.3.2"
4+
short_version = __version__
5+
6+
7+
def parse_version_info(version_str: str) -> Tuple:
8+
"""Parse version from a string.
9+
10+
Args:
11+
version_str (str): A string represents a version info.
12+
13+
Returns:
14+
tuple: A sequence of integer and string represents version.
15+
"""
16+
_version_info = []
17+
for x in version_str.split("."):
18+
if x.isdigit():
19+
_version_info.append(int(x))
20+
elif x.find("rc") != -1:
21+
patch_version = x.split("rc")
22+
_version_info.append(int(patch_version[0]))
23+
_version_info.append(f"rc{patch_version[1]}")
24+
return tuple(_version_info)
25+
26+
27+
version_info = parse_version_info(__version__)

setup.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import os
2+
import sys
3+
import subprocess
4+
from setuptools import setup, find_packages
5+
from setuptools.command.install import install
6+
7+
8+
pwd = os.path.dirname(__file__)
9+
version_file = "gpt_server/version.py"
10+
11+
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+
def readme():
34+
with open(os.path.join(pwd, "README.md"), encoding="utf-8") as f:
35+
content = f.read()
36+
return content
37+
38+
39+
def get_version():
40+
with open(os.path.join(pwd, version_file), "r") as f:
41+
exec(compile(f.read(), version_file, "exec"))
42+
return locals()["__version__"]
43+
44+
45+
setup(
46+
name="gpt_server",
47+
version=get_version(),
48+
description="gpt_server是一个用于生产级部署LLMs或Embedding的开源框架。",
49+
long_description=readme(),
50+
long_description_content_type="text/markdown",
51+
author="Yu Liu",
52+
author_email="[email protected]",
53+
packages=find_packages(exclude=()),
54+
# ... 其他 setup 参数 ...
55+
cmdclass={
56+
"install": CustomInstallCommand, # 关联自定义安装类
57+
},
58+
)

0 commit comments

Comments
 (0)