source: sasview/setup.py @ bc69dcc

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 bc69dcc was 202c1ef, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #5 fixing mac build

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