from setuptools import setup, find_packages from setuptools.extension import Extension from setuptools.config import read_configuration from distutils.command.build_ext import build_ext from Cython.Build import cythonize import numpy 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) 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"]), ] 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', ['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'], include_dirs=['ObservationSim/Instrument/Chip/libCTI/src/', '/usr/include'] )] # setup( # name = "slssim_disperse", # ext_modules = cythonize(extensions), # ) setup(name='CSSTSim', version='2.1.0', packages=find_packages(), 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' ], package_data = { 'ObservationSim.Astrometry.lib': ['libshao.so'], 'ObservationSim.Instrument.Chip.libBF': ['libmoduleBF.so'], 'ObservationSim.Instrument.Chip.libCTI': ['libmoduleCTI.so'], 'ObservationSim.MockObject.data': ['*.dat'], 'ObservationSim.MockObject.data.led': ['*.fits'], 'ObservationSim.Instrument.data': ['*.txt', '*.dat', '*.json'], 'ObservationSim.Instrument.data.field_distortion': ['*.pickle'], 'ObservationSim.Instrument.data.ccd': ['*.txt'], 'ObservationSim.Instrument.data.filters': ['*.txt', '*.list', '*.dat'], 'ObservationSim.Instrument.data.throughputs': ['*.txt', '*.dat'], 'ObservationSim.Instrument.data.sls_conf': ['*.conf', '*.fits'], 'ObservationSim.Instrument.data.flatCube': ['*.fits'], 'Catalog.data': ['*.fits'], 'ObservationSim.Config.Header':['*.header','*.lst'], 'ObservationSim.Straylight.data': ['*.dat'], 'ObservationSim.Straylight.data.sky': ['*.dat'], 'ObservationSim.Straylight.lib': ['*'], }, ext_modules = cythonize(extensions) + df_module + cti_module, cmdclass={'build_ext': build_ext} )