source: sasview/setup.py @ 7983000f

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 7983000f was 5c77050, checked in by Jae Cho <jhjcho@…>, 13 years ago

another correction for argv index

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