setup.py 2.09 KB
Newer Older
Shuai Feng's avatar
Shuai Feng committed
1
import setuptools
Shuai Feng's avatar
Shuai Feng committed
2
3
import os
import re
Shuai Feng's avatar
Shuai Feng committed
4

Shuai Feng's avatar
Shuai Feng committed
5
6
7
8
9
10
11
12
13
14
with open("README.md", "r") as fh:
    long_description = fh.read()

with open("requirements.txt", "r") as f:
    requirements = [
        req.strip()
        for req in f.readlines()
        if not req.startswith("#") and req.__contains__("==")
    ]

Shuai Feng's avatar
Shuai Feng committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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__ 定义")

Shuai Feng's avatar
Shuai Feng committed
30
setuptools.setup(
Shuai Feng's avatar
Shuai Feng committed
31
32
33
34
35
36
    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
Shuai Feng's avatar
Shuai Feng committed
37
    long_description=long_description,
Shuai Feng's avatar
Shuai Feng committed
38
39
40
    long_description_content_type = "text/markdown",
    url = 'https://csst-tb.bao.ac.cn/code/csst-sims/csst_ifs_gehong',
    project_urls = {
Shuai Feng's avatar
Shuai Feng committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        'Source': 'https://csst-tb.bao.ac.cn/code/csst-sims/csst_ifs_gehong',
    },
    packages=setuptools.find_packages(),
    classifiers=["Development Status :: 5 - Production/Stable",
                 "Intended Audience :: Science/Research",
                 "License :: OSI Approved :: MIT License",
                 "Operating System :: OS Independent",
                 "Programming Language :: Python :: 3.11",
                 "Topic :: Scientific/Engineering :: Physics",
                 "Topic :: Scientific/Engineering :: Astronomy"],
    package_dir={'csst_ifs_gehong': 'csst_ifs_gehong'},
    # include_package_data=True,
    package_data={"": ["LICENSE", "README.md"],
                  "csst_ifs_gehong": [
                      "data/*",
                  ]},
    python_requires='>=3.11',
    install_requires=requirements,
Shuai Feng's avatar
Shuai Feng committed
59
)