1 | """ |
---|
2 | Setup for SansView |
---|
3 | #TODO: Add checks to see that all the dependencies are on the system |
---|
4 | """ |
---|
5 | import sys |
---|
6 | import os |
---|
7 | #from distutils.core import setup, Extension |
---|
8 | from setuptools import setup, Extension, find_packages |
---|
9 | try: |
---|
10 | from numpy.distutils.misc_util import get_numpy_include_dirs |
---|
11 | NUMPY_INC = get_numpy_include_dirs()[0] |
---|
12 | except: |
---|
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 | |
---|
20 | package_dir = {} |
---|
21 | package_data = {} |
---|
22 | packages = [] |
---|
23 | ext_modules = [] |
---|
24 | |
---|
25 | # TODO check for sans/__init__.py |
---|
26 | |
---|
27 | # sans.invariant |
---|
28 | package_dir["sans.invariant"] = "sansinvariant/src/sans/invariant" |
---|
29 | packages.extend(["sans.invariant"]) |
---|
30 | |
---|
31 | # sans.guiframe |
---|
32 | guiframe_path = os.path.join("sansguiframe", "src", "sans", "guiframe") |
---|
33 | package_dir["sans.guiframe"] = guiframe_path |
---|
34 | package_dir["sans.guiframe.local_perspectives"] = os.path.join(guiframe_path, "local_perspectives") |
---|
35 | package_data["sans.guiframe"] = ['images/*', 'media/*'] |
---|
36 | packages.extend(["sans.guiframe", "sans.guiframe.local_perspectives"]) |
---|
37 | # build local plugin |
---|
38 | for 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 |
---|
45 | package_dir["sans.dataloader"] = os.path.join("sansdataloader", "src", "sans", "dataloader") |
---|
46 | package_data["sans.dataloader.readers"] = ['defaults.xml'] |
---|
47 | packages.extend(["sans.dataloader","sans.dataloader.readers"]) |
---|
48 | |
---|
49 | # sans.calculator |
---|
50 | package_dir["sans.calculator"] = "sanscalculator/src/sans/calculator" |
---|
51 | packages.extend(["sans.calculator"]) |
---|
52 | |
---|
53 | # sans.pr |
---|
54 | numpy_incl_path = os.path.join(NUMPY_INC, "numpy") |
---|
55 | srcdir = os.path.join("pr_inversion", "src", "sans", "pr", "c_extensions") |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | package_dir["sans.pr.core"] = srcdir |
---|
60 | package_dir["sans.pr"] = os.path.join("pr_inversion", "src","sans", "pr") |
---|
61 | packages.extend(["sans.pr","sans.pr.core"]) |
---|
62 | ext_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) |
---|
70 | package_dir["sans.fit"] = "park_integration/src/sans/fit" |
---|
71 | packages.append("sans.fit") |
---|
72 | |
---|
73 | # inversion view |
---|
74 | package_dir["sans.perspectives"] = "inversionview/src/sans/perspectives" |
---|
75 | package_dir["sans.perspectives.pr"] = "inversionview/src/sans/perspectives/pr" |
---|
76 | packages.extend(["sans.perspectives","sans.perspectives.pr"]) |
---|
77 | package_data["sans.perspectives.pr"] = ['images/*'] |
---|
78 | |
---|
79 | # Invariant view |
---|
80 | package_dir["sans.perspectives"] = os.path.join("invariantview", "src", "sans", "perspectives") |
---|
81 | package_dir["sans.perspectives.invariant"] = os.path.join("invariantview", "src", "sans", "perspectives", "invariant") |
---|
82 | |
---|
83 | package_data['sans.perspectives.invariant'] = [os.path.join("media",'*')] |
---|
84 | packages.extend(["sans.perspectives","sans.perspectives.invariant"]) |
---|
85 | |
---|
86 | # Fitting view |
---|
87 | package_dir["sans.perspectives"] = os.path.join("fittingview", "src", "sans", "perspectives"), |
---|
88 | package_dir["sans.perspectives.fitting"] = os.path.join("fittingview", "src", "sans", "perspectives", "fitting") |
---|
89 | package_data['sans.perspectives.fitting'] = ['media/*'] |
---|
90 | packages.extend(["sans.perspectives", "sans.perspectives.fitting"]) |
---|
91 | |
---|
92 | # Calculator view |
---|
93 | package_dir["sans.perspectives"] = "calculatorview/src/sans/perspectives" |
---|
94 | package_dir["sans.perspectives.calculator"] = os.path.join("calculatorview", "src", "sans", "perspectives", "calculator") |
---|
95 | package_data['sans.perspectives.calculator'] = ['images/*', 'media/*'] |
---|
96 | packages.extend(["sans.perspectives", "sans.perspectives.calculator"]) |
---|
97 | |
---|
98 | # Data util |
---|
99 | package_dir["data_util"] = "sansutil" |
---|
100 | packages.extend(["data_util"]) |
---|
101 | |
---|
102 | # Plottools |
---|
103 | package_dir["danse"] = os.path.join("plottools", "src", "danse") |
---|
104 | package_dir["danse.common"] = os.path.join("plottools", "src", "danse", "common") |
---|
105 | package_dir["danse.common.plottools"] = os.path.join("plottools", "src", "danse", "common", "plottools") |
---|
106 | packages.extend(["danse", "danse.common", "danse.common.plottools"]) |
---|
107 | |
---|
108 | # Park 1.2.1 |
---|
109 | package_dir["park"]="park-1.2.1/park" |
---|
110 | packages.extend(["park"]) |
---|
111 | package_data["park"] = ['park-1.2.1/*.txt', 'park-1.2.1/park.epydoc'] |
---|
112 | ext_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 |
---|
118 | srcdir = os.path.join("sansmodels", "src", "sans", "models", "c_extensions") |
---|
119 | igordir = os.path.join("sansmodels", "src","sans", "models", "libigor") |
---|
120 | c_model_dir = os.path.join("sansmodels", "src", "sans", "models", "c_models") |
---|
121 | smear_dir = os.path.join("sansmodels", "src", "sans", "models", "c_smearer") |
---|
122 | |
---|
123 | IGNORED_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 | |
---|
136 | if not os.name=='nt': |
---|
137 | IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"]) |
---|
138 | |
---|
139 | |
---|
140 | EXTENSIONS = [".c", ".cpp"] |
---|
141 | |
---|
142 | def 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 | |
---|
161 | model_sources = [] |
---|
162 | append_file(file_list=model_sources, dir_path=srcdir) |
---|
163 | append_file(file_list=model_sources, dir_path=igordir) |
---|
164 | append_file(file_list=model_sources, dir_path=c_model_dir) |
---|
165 | smear_sources = [] |
---|
166 | append_file(file_list=smear_sources, dir_path=smear_dir) |
---|
167 | |
---|
168 | |
---|
169 | package_dir["sans"] = os.path.join("sansmodels", "src", "sans") |
---|
170 | package_dir["sans.models"] = os.path.join("sansmodels", "src", "sans", "models") |
---|
171 | package_dir["sans.models.sans_extension"] = srcdir |
---|
172 | |
---|
173 | package_data['sans.models'] = [os.path.join('media', "*")] |
---|
174 | packages.extend(["sans","sans.models","sans.models.sans_extension"]) |
---|
175 | |
---|
176 | smearer_sources = [os.path.join(smear_dir, "smearer.cpp"), |
---|
177 | os.path.join(smear_dir, "smearer_module.cpp")] |
---|
178 | |
---|
179 | if not os.name=='nt': |
---|
180 | smearer_sources.append(os.path.join(igordir, "winFuncs.c")) |
---|
181 | |
---|
182 | ext_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 |
---|
198 | package_dir["sans.sansview"] = "sansview" |
---|
199 | package_data['sans.sansview'] = ['images/*', 'media/*', 'plugins/*', 'test/*'] |
---|
200 | packages.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'] |
---|
204 | required = ['lxml', 'numpy>=1.3.0', 'matplotlib', |
---|
205 | 'pil','periodictable>=1.3.0', 'unittest-xml-reporting'] |
---|
206 | if sys.platform=='win32': |
---|
207 | required.extend(['comtypes','pywin32', 'pisa', 'html5lib', 'reportlab']) |
---|
208 | |
---|
209 | # Set up SansView |
---|
210 | setup( |
---|
211 | name="sansview", |
---|
212 | version = "2.0.1", |
---|
213 | description = "SansView application", |
---|
214 | author = "University of Tennessee", |
---|
215 | author_email = "sansdanse@gmail.com", |
---|
216 | url = "http://danse.chem.utk.edu", |
---|
217 | license = "PSF", |
---|
218 | keywords = "small-angle neutron scattering analysis", |
---|
219 | download_url = "https://sourceforge.net/projects/sansviewproject/files/", |
---|
220 | package_dir = package_dir, |
---|
221 | packages = packages, |
---|
222 | package_data = package_data, |
---|
223 | ext_modules = ext_modules, |
---|
224 | install_requires = required, |
---|
225 | zip_safe = False, |
---|
226 | entry_points = { |
---|
227 | 'console_scripts':[ |
---|
228 | "sansview = sans.sansview.sansview:run", |
---|
229 | ] |
---|
230 | } |
---|
231 | ) |
---|