setup.py 3.75 KB
Newer Older
Fang Yuedong's avatar
Fang Yuedong committed
1
2
from setuptools import setup, find_packages

Xin Zhang's avatar
Xin Zhang committed
3
4
from setuptools.extension import Extension
from setuptools.config import read_configuration
5
from distutils.command.build_ext import build_ext
Xin Zhang's avatar
Xin Zhang committed
6
7
8
9
10

from Cython.Build import cythonize

import numpy

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
29
30
31
32
33
34
35
36
37
38
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
39
40
41
42
43
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',
44
                    ['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
45
                    include_dirs=['ObservationSim/Instrument/Chip/libCTI/src/', '/usr/include']
46
47
)]

Xin Zhang's avatar
Xin Zhang committed
48
49
50
51
52
53

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

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