-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
99 lines (85 loc) · 2.92 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from __future__ import print_function
#from setuptools import setup, Extension
import numpy, os, sys, os.path
import glob
# need this to use f2py from within numpy
from numpy.distutils.core import setup, Extension
if '--use-cython' in sys.argv:
USE_CYTHON = True
sys.argv.remove('--use-cython')
else:
USE_CYTHON = False
ext = '.pyx' if USE_CYTHON else '.c'
# standard YMW16 .c files
ymw16_sources=['dmdtau.c',
'dora.c',
'fermibubble.c',
'frb_d.c',
'galcen.c',
'gum.c',
'lmc.c',
'localbubble.c',
'ne_crd.c','nps.c',
'smc.c',
'spiral.c',
'thick.c',
'thin.c',
'ymw16par.c']
# check for required modules
try:
import astropy
except ImportError as e:
print("ERROR! You are missing a dependency!")
print(e)
raise
try:
import pint
except ImportError:
print('You are missing PINT: certain functionality may not work')
try:
import pygsm
import healpy
except ImportError:
print('You are missing PyGSM: certain functionality may not work')
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
packages = ['skymodel','skymodel.ne2001','skymodel.ymw16','skymodel.data']
ymw16_sources = ['skymodel/ymw16/src/' + x for x in ["ymw16_dmdtau" + ext] + ymw16_sources]
extensions=[
Extension("skymodel.ymw16.ymw16_dmdtau",
ymw16_sources,
language='c',
libraries=['m'],
extra_compile_args=['-fPIC','-fcommon'],
extra_link_args=['-fPIC']),
Extension(name='skymodel.ne2001.ne2001',
sources=['skymodel/ne2001/src/dmdsm.NE2001.f',
'skymodel/ne2001/src/density.NE2001.f',
'skymodel/ne2001/src/NE2001.f',
'skymodel/ne2001/src/neclumpN.NE2001.f',
'skymodel/ne2001/src/neLISM.NE2001.f',
'skymodel/ne2001/src/nevoidN.NE2001.f',
'skymodel/ne2001/src/scattering98.f'],
f2py_options=['']
)
]
if USE_CYTHON:
from Cython.Build import cythonize, build_ext
extensions = cythonize(extensions)
setup(
name="skymodel",
author = "D. Kaplan/NANOGrav",
author_email = "[email protected]",
description = ("Set of tools for sky models"),
license = "BSD",
#cmdclass={ "version": Version},
#keywords = "MWA radio",
#url = "http://mwa-lfd.haystack.mit.edu",
packages=packages,
#package_dir={'mwapy':'mwapy','':'configs'},
scripts=glob.glob('scripts/*.py'),
ext_modules=extensions,
long_description=read('README.md'),
# put the data files in same place as the python module
data_files=[('skymodel/data/', glob.glob('data/*.dat') + glob.glob('data/*.inp') + glob.glob('data/*.txt'))]
)