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(os.getcwd(), "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 | "winFuncs.c"] |
---|
135 | EXTENSIONS = [".c", ".cpp"] |
---|
136 | |
---|
137 | def append_file(file_list, dir_path): |
---|
138 | """ |
---|
139 | Add sources file to sources |
---|
140 | """ |
---|
141 | for f in os.listdir(dir_path): |
---|
142 | if os.path.isfile(os.path.join(dir_path, f)): |
---|
143 | _, ext = os.path.splitext(f) |
---|
144 | if ext.lower() in EXTENSIONS and f not in IGNORED_FILES: |
---|
145 | file_list.append(os.path.join(dir_path, f)) |
---|
146 | elif os.path.isdir(os.path.join(dir_path, f)) and \ |
---|
147 | not f.startswith("."): |
---|
148 | sub_dir = os.path.join(dir_path, f) |
---|
149 | for new_f in os.listdir(sub_dir): |
---|
150 | if os.path.isfile(os.path.join(sub_dir, new_f)): |
---|
151 | _, ext = os.path.splitext(new_f) |
---|
152 | if ext.lower() in EXTENSIONS and\ |
---|
153 | new_f not in IGNORED_FILES: |
---|
154 | file_list.append(os.path.join(sub_dir, new_f)) |
---|
155 | |
---|
156 | model_sources = [] |
---|
157 | append_file(file_list=model_sources, dir_path=srcdir) |
---|
158 | append_file(file_list=model_sources, dir_path=igordir) |
---|
159 | append_file(file_list=model_sources, dir_path=c_model_dir) |
---|
160 | smear_sources = [] |
---|
161 | append_file(file_list=smear_sources, dir_path=smear_dir) |
---|
162 | |
---|
163 | |
---|
164 | package_dir["sans"] = os.path.join("sansmodels", "src", "sans") |
---|
165 | package_dir["sans.models"] = os.path.join("sansmodels", "src", "sans", "models") |
---|
166 | package_dir["sans.models.sans_extension"] = srcdir |
---|
167 | |
---|
168 | package_data['sans.models'] = [os.path.join('media', "*")] |
---|
169 | packages.extend(["sans","sans.models","sans.models.sans_extension"]) |
---|
170 | |
---|
171 | ext_modules.extend( [ Extension("sans.models.sans_extension.c_models", |
---|
172 | sources=model_sources, |
---|
173 | include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]), |
---|
174 | # Smearer extension |
---|
175 | Extension("sans.models.sans_extension.smearer", |
---|
176 | sources = [os.path.join(smear_dir, "smearer.cpp"), |
---|
177 | os.path.join(smear_dir, "smearer_module.cpp"),], |
---|
178 | include_dirs=[smear_dir, numpy_incl_path]), |
---|
179 | |
---|
180 | Extension("sans.models.sans_extension.smearer2d_helper", |
---|
181 | sources = [os.path.join(smear_dir, |
---|
182 | "smearer2d_helper_module.cpp"), |
---|
183 | os.path.join(smear_dir, "smearer2d_helper.cpp"),], |
---|
184 | include_dirs=[smear_dir,numpy_incl_path]) |
---|
185 | ] ) |
---|
186 | |
---|
187 | # SansView |
---|
188 | package_dir["sans.sansview"] = "sansview" |
---|
189 | package_data['sans.sansview'] = ['images/*', 'media/*', 'plugins/*', 'test/*'] |
---|
190 | packages.append("sans.sansview") |
---|
191 | |
---|
192 | #required = ['lxml>=2.2.2', 'numpy>=1.4.1', 'matplotlib>=0.99.1.1', 'wxPython>=2.8.11', |
---|
193 | # 'pil','periodictable>=1.3.0', 'scipy>=0.7.2'] |
---|
194 | required = ['lxml>=2.2.2', 'numpy>=1.3.0', 'matplotlib>=0.99.1.1', |
---|
195 | 'pil','periodictable>=1.3.0'] |
---|
196 | if sys.platform=='win32': |
---|
197 | required.extend(['comtypes','pywin32', 'pisa', 'html5lib', 'reportlab']) |
---|
198 | |
---|
199 | # Set up SansView |
---|
200 | setup( |
---|
201 | name="sansview", |
---|
202 | version = "2.0.1", |
---|
203 | description = "SansView application", |
---|
204 | author = "University of Tennessee", |
---|
205 | author_email = "sansdanse@gmail.com", |
---|
206 | url = "http://danse.chem.utk.edu", |
---|
207 | license = "PSF", |
---|
208 | keywords = "small-angle neutron scattering analysis", |
---|
209 | download_url = "https://sourceforge.net/projects/sansviewproject/files/", |
---|
210 | package_dir = package_dir, |
---|
211 | packages = packages, |
---|
212 | package_data = package_data, |
---|
213 | ext_modules = ext_modules, |
---|
214 | install_requires = required, |
---|
215 | entry_points = { |
---|
216 | 'console_scripts':[ |
---|
217 | "sansview = sans.sansview.sansview:run", |
---|
218 | ] |
---|
219 | } |
---|
220 | ) |
---|