-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
177 lines (137 loc) · 6.72 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#cython: language_level=3, boundscheck=False
from __future__ import print_function
import pip
import time
#Check Cython installation
print('Checking Ctyhon')
try:
import Cython
cyv=Cython.__version__
print('OK! (Version %s)'%cyv)
except:
print('Cython is not present, I will install it for you my lord')
pip.main(['install','Cython'])
#Check CythonGSL installation
print('Checking CtyhonGSL')
try:
import cython_gsl
print('OK!')
except:
print('Cython is not present, I will install it for you my lord')
pip.main(['install','CythonGSL'])
#Check Scipy>1.0 installation
print('Checking Scipy>1.0')
try:
import scipy
scv=scipy.__version__
scvl=scv.split('.')
if int(scvl[0])>0 or int(scvl[1])>19:
print('OK! (Version %s)'%scv)
else:
print('Version %s too old. I will install the lastest version' % scv)
pip.main(['install','scipy'])
except:
print('Scipy is not present, I will install it for you my lord')
pip.main(['install','scipy'])
#from setuptools import setup
import shutil
import os
from Cython.Distutils import build_ext
from distutils.core import setup, Extension
from Cython.Build import cythonize
import sysconfig
import numpy
import cython_gsl
import sys
if sys.version_info[0]==2:
#time.sleep(5)
cmdclass_option = {}
print('You are using Python2, what a shame!')
#raise ValueError('You are using Python2, what a shame! Download Python3 to use this module. \n If you are using anaconda you can install a python3 virtual env just typing:\n "conda create -n yourenvname python=3.6 anaconda". \n Then you can activate the env with the bash command "source activate yourenvname"')
elif sys.version_info[0]==3:
print('You are using Python3, you are a wise person!')
def get_ext_filename_without_platform_suffix(filename):
name, ext = os.path.splitext(filename)
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix == ext:
return filename
ext_suffix = ext_suffix.replace(ext, '')
idx = name.find(ext_suffix)
if idx == -1:
return filename
else:
return name[:idx] + ext
class BuildExtWithoutPlatformSuffix(build_ext):
def get_ext_filename(self, ext_name):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
cmdclass_option = {'build_ext': BuildExtWithoutPlatformSuffix}
else:
raise ValueError('You are not using neither Python2 nor Python3, probably you are a time traveller from the Future or from the Past')
#cython gsl
cy_gsl_lib=cython_gsl.get_libraries()
cy_gsl_inc=cython_gsl.get_include()
cy_gsl_lib_dic=cython_gsl.get_library_dir()
#cython
cy_gsl_inc_cy=cython_gsl.get_cython_include_dir()
#numpy
np_inc=numpy.get_include()
gh=['galpynamics/src/pot_halo/pot_c_ext/general_halo.pyx']
gh_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.general_halo',sources=gh)
ih=['galpynamics/src/pot_halo/pot_c_ext/isothermal_halo.pyx']
ih_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.isothermal_halo',sources=ih)
infw=['galpynamics/src/pot_halo/pot_c_ext/nfw_halo.pyx']
infw_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.nfw_halo',sources=infw)
icnfw=['galpynamics/src/pot_halo/pot_c_ext/core_nfw_halo.pyx']
icnfw_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.core_nfw_halo',sources=icnfw,libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy, np_inc])
iab=['galpynamics/src/pot_halo/pot_c_ext/alfabeta_halo.pyx']
iab_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.alfabeta_halo',sources=iab,libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy])
itab=['galpynamics/src/pot_halo/pot_c_ext/truncated_alfabeta_halo.pyx']
itab_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.truncated_alfabeta_halo',sources=itab,libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy])
ph=['galpynamics/src/pot_halo/pot_c_ext/plummer_halo.pyx']
ph_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.plummer_halo',sources=ph)
eh=['galpynamics/src/pot_halo/pot_c_ext/einasto_halo.pyx']
eh_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.einasto_halo',sources=eh,libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy])
exh=['galpynamics/src/pot_halo/pot_c_ext/exponential_halo.pyx']
exh_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.exponential_halo',sources=exh)
vh=['galpynamics/src/pot_halo/pot_c_ext/valy_halo.pyx']
vh_ext=Extension('galpynamics.src.pot_halo.pot_c_ext.valy_halo',sources=vh)
gd=['galpynamics/src/pot_disc/pot_c_ext/integrand_functions.pyx']
gd_ext=Extension('galpynamics.src.pot_disc.pot_c_ext.integrand_functions',libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy, np_inc],sources=gd)
rd=['galpynamics/src/pot_disc/pot_c_ext/rdens_law.pyx']
rd_ext=Extension('galpynamics.src.pot_disc.pot_c_ext.rdens_law',sources=rd)
fd=['galpynamics/src/pot_disc/pot_c_ext/rflare_law.pyx']
fd_ext=Extension('galpynamics.src.pot_disc.pot_c_ext.rflare_law',sources=fd)
zd=['galpynamics/src/pot_disc/pot_c_ext/zdens_law.pyx']
zd_ext=Extension('galpynamics.src.pot_disc.pot_c_ext.zdens_law',sources=zd)
vcirc=['galpynamics/src/pot_disc/pot_c_ext/integrand_vcirc.pyx']
vcirc_ext=Extension('galpynamics.src.pot_disc.pot_c_ext.integrand_vcirc', sources=vcirc,libraries=cy_gsl_lib,library_dirs=[cy_gsl_lib_dic],include_dirs=[cy_gsl_inc_cy, np_inc])
#ext_modules=cythonize([cy_ext,gh_ext,ih_ext,infw_ext,gd_ext,rd_ext,fd_ext])
#extra_compile_args = ['-std=c99']
#sturct_c_src=['galpynamics/src/pot_disc/pot_c_ext/struct.c']
#struct_c_ext = Extension('galpynamics/src/pot_disc/pot_c_ext/struct',
#sources=sturct_c_src,
#extra_compile_args=extra_compile_args
#)
ext_modules=cythonize([gh_ext,ih_ext,infw_ext,icnfw_ext,gd_ext,rd_ext,fd_ext,iab_ext,itab_ext,ph_ext,eh_ext,vh_ext,exh_ext,zd_ext,vcirc_ext])
setup(
name='galpynamics',
version='0.3.0dev0',
author='Giuliano Iorio',
author_email='',
url='',
cmdclass=cmdclass_option,
packages=['galpynamics','galpynamics/src','galpynamics/src/pot_halo','galpynamics/src/pot_halo/pot_c_ext','galpynamics/src/pardo','galpynamics/src/pot_disc', 'galpynamics/src/pot_disc/pot_c_ext', 'galpynamics/src/galpotential', 'galpynamics/src/discHeight', 'galpynamics/src/discHeight/c_ext' , 'galpynamics/src/fitlib' ],
ext_modules=ext_modules,
include_dirs=[np_inc,cython_gsl.get_include()],
install_requires=['numpy>=1.9', 'scipy>=0.19', 'matplotlib','emcee', 'termcolor'],
zip_safe=False
)
'''
try:
shutil.rmtree('build')
shutil.rmtree('dist')
shutil.rmtree('galpynamics.egg-info')
except:
pass
'''