setup.py 4.17 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
61

# setup(
#     name = "slssim_disperse",
#     ext_modules = cythonize(extensions),
# )

Fang Yuedong's avatar
Fang Yuedong committed
62
setup(name='CSSTSim', 
63
    version='2.1.0', 
Fang Yuedong's avatar
Fang Yuedong committed
64
    packages=find_packages(),
65
    install_requires=[
66
67
68
69
70
71
72
73
74
75
76
        # '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'
77
    ],
Fang Yuedong's avatar
Fang Yuedong committed
78
79
    package_data = {
        'ObservationSim.Astrometry.lib': ['libshao.so'], 
Wei Chengliang's avatar
Wei Chengliang committed
80
81
        'ObservationSim.Instrument.Chip.libBF': ['libmoduleBF.so'],
        'ObservationSim.Instrument.Chip.libCTI': ['libmoduleCTI.so'],
Fang Yuedong's avatar
Fang Yuedong committed
82
        'ObservationSim.MockObject.data': ['*.dat'], 
83
        'ObservationSim.MockObject.data.led': ['*.fits'],
Fang Yuedong's avatar
Fang Yuedong committed
84
85
        'ObservationSim.Instrument.data': ['*.txt', '*.dat', '*.json'],
        'ObservationSim.Instrument.data.field_distortion': ['*.pickle'],
86
        'ObservationSim.Instrument.data.ccd': ['*.txt','*.json'], 
Fang Yuedong's avatar
Fang Yuedong committed
87
        'ObservationSim.Instrument.data.filters': ['*.txt', '*.list', '*.dat'], 
88
        'ObservationSim.Instrument.data.throughputs': ['*.txt', '*.dat'], 
Fang Yuedong's avatar
Fang Yuedong committed
89
        'ObservationSim.Instrument.data.sls_conf': ['*.conf', '*.fits'],
90
        'ObservationSim.Instrument.data.flatCube': ['*.fits'],
91
        'Catalog.data': ['*.fits','*.so'],
Fang Yuedong's avatar
Fang Yuedong committed
92
        'ObservationSim.Config.Header':['*.header','*.lst'],
93
        'ObservationSim.Straylight.data': ['*.dat'],
94
        'ObservationSim.Straylight.data.sky': ['*.dat'],
95
        'ObservationSim.Straylight.lib': ['*'],
Fang Yuedong's avatar
Fang Yuedong committed
96
    },
Wei Chengliang's avatar
Wei Chengliang committed
97
    ext_modules = cythonize(extensions) + df_module + cti_module,
98
    cmdclass={'build_ext': build_ext}
xin's avatar
xin committed
99
)