source: sasview/setup.py @ 0e307de

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 0e307de was 0e307de, checked in by Jae Cho <jhjcho@…>, 8 years ago

give option for disabling openmp

  • Property mode set to 100644
File size: 10.9 KB
Line 
1"""
2    Setup for SansView
3    #TODO: Add checks to see that all the dependencies are on the system
4"""
5import sys
6import os
7import platform
8from setuptools import setup, Extension, find_packages
9from distutils.command.build_ext import build_ext
10
11try:
12    from numpy.distutils.misc_util import get_numpy_include_dirs
13    NUMPY_INC = get_numpy_include_dirs()[0]
14except:
15    try:
16        import numpy
17        NUMPY_INC = os.path.join(os.path.split(numpy.__file__)[0],"core","include")
18    except:
19        print "\nNumpy is needed to build SansView. Try easy_install numpy.\n  %s" % str(sys.exc_value)
20        sys.exit(0)
21
22# Manage version number ######################################
23import sansview
24VERSION = sansview.__version__
25##############################################################
26
27package_dir = {}
28package_data = {}
29packages = []
30ext_modules = []
31
32if sys.argv[1] == "-nomp":
33    # Disnable OpenMP
34    copt = {}
35    lopt = {}
36else:
37    # Options to enable OpenMP
38    copt =  {'msvc': ['/openmp'],
39             'mingw32' : ['-fopenmp'],
40             'unix' : ['-fopenmp']}
41    lopt =  {'msvc': ['/MANIFEST'],
42             'mingw32' : ['-fopenmp'],
43             'unix' : ['-lgomp']}
44
45class build_ext_subclass( build_ext ):
46    def build_extensions(self):
47        # Get 64-bitness
48        if sys.version_info >= (2, 6):
49            is_64bits = sys.maxsize > 2**32
50        else:
51            # 'sys.maxsize' and 64bit: Not supported for python2.5
52            is_64bits = False
53       
54        c = self.compiler.compiler_type
55        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
56       
57        if not (sys.platform=='darwin' and not is_64bits):
58            if copt.has_key(c):
59               for e in self.extensions:
60                   e.extra_compile_args = copt[ c ]
61            if lopt.has_key(c):
62                for e in self.extensions:
63                    e.extra_link_args = lopt[ c ]
64                   
65        build_ext.build_extensions(self)
66
67
68# sans.invariant
69package_dir["sans.invariant"] = "sansinvariant/src/sans/invariant"
70packages.extend(["sans.invariant"])
71
72# sans.guiframe
73guiframe_path = os.path.join("sansguiframe", "src", "sans", "guiframe")
74package_dir["sans.guiframe"] = guiframe_path
75package_dir["sans.guiframe.local_perspectives"] = os.path.join(guiframe_path, "local_perspectives")
76package_data["sans.guiframe"] = ['images/*', 'media/*']
77packages.extend(["sans.guiframe", "sans.guiframe.local_perspectives"])
78# build local plugin
79for dir in os.listdir(os.path.join(guiframe_path, "local_perspectives")):
80    if dir not in ['.svn','__init__.py', '__init__.pyc']:
81        package_name = "sans.guiframe.local_perspectives." + dir
82        packages.append(package_name)
83        package_dir[package_name] = os.path.join(guiframe_path, "local_perspectives", dir)
84
85# sans.dataloader
86package_dir["sans.dataloader"] = os.path.join("sansdataloader", "src", "sans", "dataloader")
87package_data["sans.dataloader.readers"] = ['defaults.xml']
88packages.extend(["sans.dataloader","sans.dataloader.readers"])
89
90# sans.calculator
91package_dir["sans.calculator"] = "sanscalculator/src/sans/calculator"
92packages.extend(["sans.calculator"])
93   
94# sans.pr
95numpy_incl_path = os.path.join(NUMPY_INC, "numpy")
96srcdir  = os.path.join("pr_inversion", "src", "sans", "pr", "c_extensions")
97
98
99   
100package_dir["sans.pr.core"] = srcdir
101package_dir["sans.pr"] = os.path.join("pr_inversion", "src","sans", "pr")
102packages.extend(["sans.pr","sans.pr.core"])
103ext_modules.append( Extension("sans.pr.core.pr_inversion",
104                              sources = [ os.path.join(srcdir, "Cinvertor.c"),
105                                         os.path.join(srcdir, "invertor.c"),
106                                         ],
107                              include_dirs=[numpy_incl_path],
108                              ) )
109       
110# sans.fit (park integration)
111package_dir["sans.fit"] = "park_integration/src/sans/fit"
112packages.append("sans.fit")
113
114# inversion view
115package_dir["sans.perspectives"] = "inversionview/src/sans/perspectives"
116package_dir["sans.perspectives.pr"] = "inversionview/src/sans/perspectives/pr"
117packages.extend(["sans.perspectives","sans.perspectives.pr"])
118package_data["sans.perspectives.pr"] = ['images/*']
119
120# Invariant view
121package_dir["sans.perspectives"] = os.path.join("invariantview", "src", "sans", "perspectives")
122package_dir["sans.perspectives.invariant"] = os.path.join("invariantview", "src", "sans", "perspectives", "invariant")
123               
124package_data['sans.perspectives.invariant'] = [os.path.join("media",'*')]
125packages.extend(["sans.perspectives","sans.perspectives.invariant"]) 
126
127# Fitting view
128package_dir["sans.perspectives"] = os.path.join("fittingview", "src", "sans", "perspectives"),
129package_dir["sans.perspectives.fitting"] = os.path.join("fittingview", "src", "sans", "perspectives", "fitting")
130package_data['sans.perspectives.fitting'] = ['media/*','plugin_models/*']
131packages.extend(["sans.perspectives", "sans.perspectives.fitting"])
132
133# Calculator view
134package_dir["sans.perspectives"] = "calculatorview/src/sans/perspectives"
135package_dir["sans.perspectives.calculator"] = os.path.join("calculatorview", "src", "sans", "perspectives", "calculator")
136package_data['sans.perspectives.calculator'] = ['images/*', 'media/*']
137packages.extend(["sans.perspectives", "sans.perspectives.calculator"])
138     
139# Data util
140package_dir["data_util"] = "sansutil"
141packages.extend(["data_util"])
142
143# Plottools
144package_dir["danse"] = os.path.join("plottools", "src", "danse")
145package_dir["danse.common"] = os.path.join("plottools", "src", "danse", "common")
146package_dir["danse.common.plottools"] = os.path.join("plottools", "src", "danse", "common", "plottools")
147packages.extend(["danse", "danse.common", "danse.common.plottools"])
148
149# Park 1.2.1
150package_dir["park"]="park-1.2.1/park"
151packages.extend(["park"])
152package_data["park"] = ['park-1.2.1/*.txt', 'park-1.2.1/park.epydoc']
153ext_modules.append( Extension("park._modeling",
154                              sources = [ os.path.join("park-1.2.1", "park", "lib", "modeling.cc"),
155                                         os.path.join("park-1.2.1", "park", "lib", "resolution.c"),
156                                         ],
157                              ) )
158
159# Sans models
160srcdir  = os.path.join("sansmodels", "src", "sans", "models", "c_extensions")
161igordir = os.path.join("sansmodels", "src","sans", "models", "libigor")
162c_model_dir = os.path.join("sansmodels", "src", "sans", "models", "c_models")
163smear_dir  = os.path.join("sansmodels", "src", "sans", "models", "c_smearer")
164
165IGNORED_FILES = ["a.exe",
166                 "__init__.py"
167                 ".svn",
168                   "lineparser.py",
169                   "run.py",
170                   "CGaussian.cpp",
171                   "CLogNormal.cpp",
172                   "CLorentzian.cpp",
173                   "CSchulz.cpp",
174                   "WrapperGenerator.py",
175                   "wrapping.py"
176                   ]
177
178if not os.name=='nt':
179    IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])
180
181
182EXTENSIONS = [".c", ".cpp"]
183
184def append_file(file_list, dir_path):
185    """
186    Add sources file to sources
187    """
188    for f in os.listdir(dir_path):
189        if os.path.isfile(os.path.join(dir_path, f)):
190            _, ext = os.path.splitext(f)
191            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
192                file_list.append(os.path.join(dir_path, f)) 
193        elif os.path.isdir(os.path.join(dir_path, f)) and \
194                not f.startswith("."):
195            sub_dir = os.path.join(dir_path, f)
196            for new_f in os.listdir(sub_dir):
197                if os.path.isfile(os.path.join(sub_dir, new_f)):
198                    _, ext = os.path.splitext(new_f)
199                    if ext.lower() in EXTENSIONS and\
200                         new_f not in IGNORED_FILES:
201                        file_list.append(os.path.join(sub_dir, new_f)) 
202       
203model_sources = []
204append_file(file_list=model_sources, dir_path=srcdir)
205append_file(file_list=model_sources, dir_path=igordir)
206append_file(file_list=model_sources, dir_path=c_model_dir)
207smear_sources = []
208append_file(file_list=smear_sources, dir_path=smear_dir)
209
210
211package_dir["sans"] = os.path.join("sansmodels", "src", "sans")
212package_dir["sans.models"] = os.path.join("sansmodels", "src", "sans", "models")
213package_dir["sans.models.sans_extension"] = srcdir
214           
215package_data['sans.models'] = [os.path.join('media', "*")]
216packages.extend(["sans","sans.models","sans.models.sans_extension"])
217   
218smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
219                  os.path.join(smear_dir, "smearer_module.cpp")]
220
221if os.name=='nt':
222    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
223
224ext_modules.extend( [ Extension("sans.models.sans_extension.c_models",
225                                sources=model_sources,                 
226                                include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path],
227                                ),       
228                    # Smearer extension
229                    Extension("sans.models.sans_extension.smearer",
230                              sources = smearer_sources,
231                              include_dirs=[igordir, smear_dir, numpy_incl_path],
232                              ),
233                   
234                    Extension("sans.models.sans_extension.smearer2d_helper",
235                              sources = [os.path.join(smear_dir, 
236                                                      "smearer2d_helper_module.cpp"),
237                                         os.path.join(smear_dir, "smearer2d_helper.cpp"),],
238                              include_dirs=[smear_dir,numpy_incl_path],
239                              )
240                    ] )
241       
242# SansView
243package_dir["sans.sansview"] = "sansview"
244package_data['sans.sansview'] = ['images/*', 'media/*', 'test/*']
245packages.append("sans.sansview")
246
247#required = ['lxml>=2.2.2', 'numpy>=1.4.1', 'matplotlib>=0.99.1.1', 'wxPython>=2.8.11',
248#            'pil','periodictable>=1.3.0', 'scipy>=0.7.2']
249required = ['lxml','periodictable>=1.3.0']
250"""
251if os.name=='nt':
252    #required.extend(['comtypes', 'pisa', 'html5lib', 'reportlab'])
253    required.extend(['pisa', 'html5lib'])
254    if sys.version_info < (2, 7):
255        required.append('comtypes')
256else:
257    required.extend(['pil'])
258"""   
259 # Set up SansView   
260setup(
261    name="sansview",
262    version = VERSION,
263    description = "SansView application",
264    author = "University of Tennessee",
265    author_email = "sansdanse@gmail.com",
266    url = "http://danse.chem.utk.edu",
267    license = "PSF",
268    keywords = "small-angle neutron scattering analysis",
269    download_url = "https://sourceforge.net/projects/sansviewproject/files/",
270    package_dir = package_dir,
271    packages = packages,
272    package_data = package_data,
273    ext_modules = ext_modules,
274    install_requires = required,
275    zip_safe = False,
276    entry_points = {
277                    'console_scripts':[
278                                       "sansview = sans.sansview.sansview:run",
279                                       ]
280                    },
281    cmdclass = {'build_ext': build_ext_subclass }
282    )   
Note: See TracBrowser for help on using the repository browser.