From 02b9627f1c050d99114e614d70bac1b92cecf45b Mon Sep 17 00:00:00 2001 From: Shuai Feng <451424498@qq.com> Date: Tue, 7 Jan 2025 16:59:07 +0800 Subject: [PATCH] update 3.0.1 --- setup.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index d5df22b..3b2f7a6 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,6 @@ import setuptools +import os +import re with open("README.md", "r") as fh: long_description = fh.read() @@ -10,17 +12,32 @@ with open("requirements.txt", "r") as f: if not req.startswith("#") and req.__contains__("==") ] +def get_version(): + # 找到 __init__.py 的路径 + init_path = os.path.join( + os.path.dirname(__file__), + "csst_ifs_gehong", + "__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__ 定义") + setuptools.setup( - name='csst_ifs_gehong', - version='3.0.0', - license='MIT', - author="Shuai Feng", - author_email='sfeng@hebtu.edu.cn', - description='The packages for the scientific data simulation of CSST-IFS', # short description + name = 'csst_ifs_gehong', + version = get_version(), + license = 'MIT', + author = "Shuai Feng", + author_email = 'sfeng@hebtu.edu.cn', + description = 'The packages for the scientific data simulation of CSST-IFS', # short description long_description=long_description, - long_description_content_type="text/markdown", - url='https://csst-tb.bao.ac.cn/code/csst-sims/csst_ifs_gehong', - project_urls={ + long_description_content_type = "text/markdown", + url = 'https://csst-tb.bao.ac.cn/code/csst-sims/csst_ifs_gehong', + project_urls = { 'Source': 'https://csst-tb.bao.ac.cn/code/csst-sims/csst_ifs_gehong', }, packages=setuptools.find_packages(), -- GitLab