setup.py 4.55 KB
Newer Older
1
2
3
4
5
6
7
8
'''
Author: Zhang Xin zhangx@bao.ac.cn
Date: 2023-08-07 11:23:28
LastEditors: Zhang Xin zhangx@bao.ac.cn
LastEditTime: 2023-10-08 14:44:19
FilePath: /undefined/Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_develop/csst-simulation/setup.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
Fang Yuedong's avatar
Fang Yuedong committed
9
10
from setuptools import setup, find_packages

Xin Zhang's avatar
Xin Zhang committed
11
12
from setuptools.extension import Extension
from setuptools.config import read_configuration
13
from distutils.command.build_ext import build_ext
Xin Zhang's avatar
Xin Zhang committed
14
15
16
17
18

from Cython.Build import cythonize

import numpy

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class CTypes(Extension): pass

class build_ext(build_ext):

    def build_extension(self, ext):
        self._ctypes = isinstance(ext, CTypes)
        return super().build_extension(ext)

    def get_export_symbols(self, ext):
        if self._ctypes:
            return ext.export_symbols
        return super().get_export_symbols(ext)

    def get_ext_filename(self, ext_name):
        if self._ctypes:
            return ext_name + '.so'
        return super().get_ext_filename(ext_name)

Xin Zhang's avatar
Xin Zhang committed
37
38
39
40
41
42
43
44
45
46
extensions = [
    Extension("ObservationSim.MockObject.SpecDisperser.disperse_c.interp", ["ObservationSim/MockObject/SpecDisperser/disperse_c/interp.pyx"],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),
    
    Extension("ObservationSim.MockObject.SpecDisperser.disperse_c.disperse", ["ObservationSim/MockObject/SpecDisperser/disperse_c/disperse.pyx"],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),
]

Wei Chengliang's avatar
Wei Chengliang committed
47
48
49
50
51
df_module = [CTypes('ObservationSim.Instrument.Chip.libBF.libmoduleBF',
                    ['ObservationSim/Instrument/Chip/libBF/diffusion_X1.c', 'ObservationSim/Instrument/Chip/libBF/nrutil.c'],
                    include_dirs=['ObservationSim/Instrument/Chip/libBF/', '/usr/include']
)]
cti_module = [CTypes('ObservationSim.Instrument.Chip.libCTI.libmoduleCTI',
52
                    ['ObservationSim/Instrument/Chip/libCTI/src/add_CTI.c', 'ObservationSim/Instrument/Chip/libCTI/src/nrutil.c', 'ObservationSim/Instrument/Chip/libCTI/src/ran1.c', 'ObservationSim/Instrument/Chip/libCTI/src/ran2.c', 'ObservationSim/Instrument/Chip/libCTI/src/poidev.c', 'ObservationSim/Instrument/Chip/libCTI/src/gammln.c', 'ObservationSim/Instrument/Chip/libCTI/src/gasdev.c', 'ObservationSim/Instrument/Chip/libCTI/src/sort.c', 'ObservationSim/Instrument/Chip/libCTI/src/creattraps.c'],
Wei Chengliang's avatar
Wei Chengliang committed
53
                    include_dirs=['ObservationSim/Instrument/Chip/libCTI/src/', '/usr/include']
54
55
)]

Xin Zhang's avatar
Xin Zhang committed
56
57
58
59
60

# setup(
#     name = "slssim_disperse",
#     ext_modules = cythonize(extensions),
# )
Zhang Xin's avatar
Zhang Xin committed
61
62
63
64
65
66
67
68
# 读取依赖列表requirements.txt
# 忽略#开头或者版本号不明确指定的条目
with open("requirements.txt", "r") as f:
    requirements = [
        req.strip()
        for req in f.readlines()
        if not req.startswith("#") and req.__contains__("==")
    ]
Xin Zhang's avatar
Xin Zhang committed
69

Fang Yuedong's avatar
Fang Yuedong committed
70
setup(name='CSSTSim', 
71
    version='2.1.0', 
Fang Yuedong's avatar
Fang Yuedong committed
72
    packages=find_packages(),
Zhang Xin's avatar
Zhang Xin committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    # install_requires=[
    #     # 'numpy>=1.18.5',
    #     # 'galsim>=2.2.4',
    #     # 'pyyaml>=5.3.1',
    #     # 'astropy>=4.0.1',
    #     # 'scipy>=1.5.0',
    #     # 'mpi4py>=3.0.3',
    #     # 'sep>=1.0.3',
    #     # 'healpy>=1.14.0',
    #     # 'h5py>=2.10.0',
    #     # 'Cython>=0.29.21',
    #     # 'numba>=0.50.1'
    # ],
    
Fang Yuedong's avatar
Fang Yuedong committed
87
88
    package_data = {
        'ObservationSim.Astrometry.lib': ['libshao.so'], 
Wei Chengliang's avatar
Wei Chengliang committed
89
90
        'ObservationSim.Instrument.Chip.libBF': ['libmoduleBF.so'],
        'ObservationSim.Instrument.Chip.libCTI': ['libmoduleCTI.so'],
Fang Yuedong's avatar
Fang Yuedong committed
91
        'ObservationSim.MockObject.data': ['*.dat'], 
92
        'ObservationSim.MockObject.data.led': ['*.fits'],
Fang Yuedong's avatar
Fang Yuedong committed
93
94
        'ObservationSim.Instrument.data': ['*.txt', '*.dat', '*.json'],
        'ObservationSim.Instrument.data.field_distortion': ['*.pickle'],
95
        'ObservationSim.Instrument.data.ccd': ['*.txt','*.json'], 
Fang Yuedong's avatar
Fang Yuedong committed
96
        'ObservationSim.Instrument.data.filters': ['*.txt', '*.list', '*.dat'], 
97
        'ObservationSim.Instrument.data.throughputs': ['*.txt', '*.dat'], 
Fang Yuedong's avatar
Fang Yuedong committed
98
        'ObservationSim.Instrument.data.sls_conf': ['*.conf', '*.fits'],
99
        'ObservationSim.Instrument.data.flatCube': ['*.fits'],
100
        'Catalog.data': ['*.fits','*.so'],
Zhang Xin's avatar
Zhang Xin committed
101
        'ObservationSim.Config.Header':['*.fits','*.lst'],
102
        'ObservationSim.Straylight.data': ['*.dat'],
103
        'ObservationSim.Straylight.data.sky': ['*.dat'],
104
        'ObservationSim.Straylight.lib': ['*'],
Fang Yuedong's avatar
Fang Yuedong committed
105
    },
Zhang Xin's avatar
Zhang Xin committed
106
107
108
    python_requires=">=3.11",  # Python版本要求
    install_requires=requirements,

Wei Chengliang's avatar
Wei Chengliang committed
109
    ext_modules = cythonize(extensions) + df_module + cti_module,
110
    cmdclass={'build_ext': build_ext}
xin's avatar
xin committed
111
)