Skip to content

Commit d26a145

Browse files
XuZhang99liutongxuan
authored andcommitted
feat: add function to retrieve Python version and update build paths accordingly.
1 parent 6205239 commit d26a145

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def get_base_dir():
4545
def join_path(*paths):
4646
return os.path.join(get_base_dir(), *paths)
4747

48+
# return the python version as a string like "310" or "311" etc
49+
def get_python_version():
50+
return f"{sys.version_info.major}{sys.version_info.minor}"
4851

4952
def get_version():
5053
# first read from environment variable
@@ -398,9 +401,9 @@ def run(self):
398401
self.run_command('test')
399402

400403
if self.arch == 'arm':
401-
ext_path = get_base_dir() + "/build/lib.linux-aarch64-cpython-311/"
404+
ext_path = get_base_dir() + f"/build/lib.linux-aarch64-cpython-{get_python_version()}/"
402405
else:
403-
ext_path = get_base_dir() + "/build/lib.linux-x86_64-cpython-311/"
406+
ext_path = get_base_dir() + f"/build/lib.linux-x86_64-cpython-{get_python_version()}/"
404407
if len(ext_path) == 0:
405408
print("Build wheel failed, not found path.")
406409
exit(1)

xllm/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import importlib.util
22
import os
33
import xllm
4-
install_path_x86 = os.path.dirname(xllm.__file__) + "/xllm_export.cpython-311-x86_64-linux-gnu.so"
5-
install_path_arm = os.path.dirname(xllm.__file__) + "/xllm_export.cpython-311-aarch64-linux-gnu.so"
4+
import sys
5+
6+
def get_python_version():
7+
return f"{sys.version_info.major}{sys.version_info.minor}"
8+
9+
install_path_x86 = os.path.dirname(xllm.__file__) + f"/xllm_export.cpython-{get_python_version()}-x86_64-linux-gnu.so"
10+
install_path_arm = os.path.dirname(xllm.__file__) + f"/xllm_export.cpython-{get_python_version()}-aarch64-linux-gnu.so"
611
if os.path.exists(install_path_x86):
712
install_path = install_path_x86
813
elif os.path.exists(install_path_arm):

0 commit comments

Comments
 (0)