Loading setup.py +19 −1 Original line number Diff line number Diff line import setuptools import re import os def get_version(): # 找到 __init__.py 的路径 init_path = os.path.join( os.path.dirname(__file__), "csst_ifs_sim", "__init__.py" ) # 读取文件内容,使用正则找出版本号 with open(init_path, "r", encoding="utf-8") as f: content = f.read() version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', content, re.M) if version_match: return version_match.group(1) raise RuntimeError("无法在 __init__.py 中找到 __version__ 定义") # 读取README.md作为长描述 with open("README.md", "r") as f: Loading @@ -16,7 +34,7 @@ with open("requirements.txt", "r") as f: setuptools.setup( name='csst_ifs_sim', # 包名 version="3.0.1", # 版本号 version=get_version(), # 版本号 author="Zhaojun Yan", # 作者 author_email="zhaojunyan@shao.ac.cn", # 邮箱 description="The CSST IFS simulation - prototype", # 短描述 Loading csst_ifs_sim/__init__.py +1 −1 File changed.Contains only whitespace changes. Show changes Loading
setup.py +19 −1 Original line number Diff line number Diff line import setuptools import re import os def get_version(): # 找到 __init__.py 的路径 init_path = os.path.join( os.path.dirname(__file__), "csst_ifs_sim", "__init__.py" ) # 读取文件内容,使用正则找出版本号 with open(init_path, "r", encoding="utf-8") as f: content = f.read() version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', content, re.M) if version_match: return version_match.group(1) raise RuntimeError("无法在 __init__.py 中找到 __version__ 定义") # 读取README.md作为长描述 with open("README.md", "r") as f: Loading @@ -16,7 +34,7 @@ with open("requirements.txt", "r") as f: setuptools.setup( name='csst_ifs_sim', # 包名 version="3.0.1", # 版本号 version=get_version(), # 版本号 author="Zhaojun Yan", # 作者 author_email="zhaojunyan@shao.ac.cn", # 邮箱 description="The CSST IFS simulation - prototype", # 短描述 Loading