source: sasview/setup.py @ 8ca5890

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 8ca5890 was 8ca5890, checked in by Mathieu Doucet <doucetm@…>, 8 years ago

Re #3 Move plugin directory for models to the user's home directory

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