source: sasview/setup.py @ fa02d95

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

Re #2 setup cleanup

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