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 | except: |
---|
12 | print "\nNumpy is needed to build SansView. Try easy_install numpy.\n" |
---|
13 | sys.exit(0) |
---|
14 | |
---|
15 | package_dir = {} |
---|
16 | package_data = {} |
---|
17 | packages = [] |
---|
18 | ext_modules = [] |
---|
19 | |
---|
20 | # TODO check for sans/__init__.py |
---|
21 | |
---|
22 | # sans.invariant |
---|
23 | package_dir["sans.invariant"] = "sansinvariant/src/sans/invariant" |
---|
24 | packages.extend(["sans.invariant"]) |
---|
25 | |
---|
26 | # sans.guiframe |
---|
27 | guiframe_path = os.path.join(os.getcwd(), "sansguiframe", "src", "sans", "guiframe") |
---|
28 | package_dir["sans.guiframe"] = guiframe_path |
---|
29 | package_dir["sans.guiframe.local_perspectives"] = os.path.join(guiframe_path, "local_perspectives") |
---|
30 | package_data["sans.guiframe"] = ['images/*', 'media/*'] |
---|
31 | packages.extend(["sans.guiframe", "sans.guiframe.local_perspectives"]) |
---|
32 | # build local plugin |
---|
33 | for 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 |
---|
40 | package_dir["sans.dataloader"] = os.path.join("sansdataloader", "src", "sans", "dataloader") |
---|
41 | package_data["sans.dataloader.readers"] = ['defaults.xml'] |
---|
42 | packages.extend(["sans.dataloader","sans.dataloader.readers"]) |
---|
43 | |
---|
44 | # sans.calculator |
---|
45 | package_dir["sans.calculator"] = "sanscalculator/src/sans/calculator" |
---|
46 | packages.extend(["sans.calculator"]) |
---|
47 | |
---|
48 | # sans.pr |
---|
49 | numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy") |
---|
50 | srcdir = os.path.join("pr_inversion", "src", "sans", "pr", "c_extensions") |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | package_dir["sans.pr.core"] = srcdir |
---|
55 | package_dir["sans.pr"] = os.path.join("pr_inversion", "src","sans", "pr") |
---|
56 | packages.extend(["sans.pr","sans.pr.core"]) |
---|
57 | ext_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) |
---|
65 | package_dir["sans.fit"] = "park_integration/src/sans/fit" |
---|
66 | packages.append("sans.fit") |
---|
67 | |
---|
68 | # inversion view |
---|
69 | package_dir["sans.perspectives"] = "inversionview/src/sans/perspectives" |
---|
70 | package_dir["sans.perspectives.pr"] = "inversionview/src/sans/perspectives/pr" |
---|
71 | packages.extend(["sans.perspectives","sans.perspectives.pr"]) |
---|
72 | package_data["sans.perspectives.pr"] = ['images/*'] |
---|
73 | |
---|
74 | # Invariant view |
---|
75 | package_dir["sans.perspectives"] = os.path.join("invariantview", "src", "sans", "perspectives") |
---|
76 | package_dir["sans.perspectives.invariant"] = os.path.join("invariantview", "src", "sans", "perspectives", "invariant") |
---|
77 | |
---|
78 | package_data['sans.perspectives.invariant'] = [os.path.join("media",'*')] |
---|
79 | packages.extend(["sans.perspectives","sans.perspectives.invariant"]) |
---|
80 | |
---|
81 | # Fitting view |
---|
82 | package_dir["sans.perspectives"] = os.path.join("fittingview", "src", "sans", "perspectives"), |
---|
83 | package_dir["sans.perspectives.fitting"] = os.path.join("fittingview", "src", "sans", "perspectives", "fitting") |
---|
84 | package_data['sans.perspectives.fitting'] = ['media/*'] |
---|
85 | packages.extend(["sans.perspectives", "sans.perspectives.fitting"]) |
---|
86 | |
---|
87 | # Calculator view |
---|
88 | package_dir["sans.perspectives"] = "calculatorview/src/sans/perspectives" |
---|
89 | package_dir["sans.perspectives.calculator"] = os.path.join("calculatorview", "src", "sans", "perspectives", "calculator") |
---|
90 | package_data['sans.perspectives.calculator'] = ['images/*', 'media/*'] |
---|
91 | packages.extend(["sans.perspectives", "sans.perspectives.calculator"]) |
---|
92 | |
---|
93 | # Data util |
---|
94 | package_dir["data_util"] = "sansutil" |
---|
95 | packages.extend(["data_util"]) |
---|
96 | |
---|
97 | # Plottools |
---|
98 | package_dir["danse"] = os.path.join("plottools", "src", "danse") |
---|
99 | package_dir["danse.common"] = os.path.join("plottools", "src", "danse", "common") |
---|
100 | package_dir["danse.common.plottools"] = os.path.join("plottools", "src", "danse", "common", "plottools") |
---|
101 | packages.extend(["danse", "danse.common", "danse.common.plottools"]) |
---|
102 | |
---|
103 | # Park 1.2.1 |
---|
104 | package_dir["park"]="park-1.2.1/park" |
---|
105 | packages.extend(["park"]) |
---|
106 | package_data["park"] = ['park-1.2.1/*.txt', 'park-1.2.1/park.epydoc'] |
---|
107 | ext_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 |
---|
113 | srcdir = os.path.join("sansmodels", "src", "sans", "models", "c_extensions") |
---|
114 | igordir = os.path.join("sansmodels", "src","sans", "models", "libigor") |
---|
115 | c_model_dir = os.path.join("sansmodels", "src", "sans", "models", "c_models") |
---|
116 | smear_dir = os.path.join("sansmodels", "src", "sans", "models", "c_smearer") |
---|
117 | |
---|
118 | IGNORED_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"] |
---|
130 | EXTENSIONS = [".c", ".cpp"] |
---|
131 | |
---|
132 | def 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 | |
---|
151 | model_sources = [] |
---|
152 | append_file(file_list=model_sources, dir_path=srcdir) |
---|
153 | append_file(file_list=model_sources, dir_path=igordir) |
---|
154 | append_file(file_list=model_sources, dir_path=c_model_dir) |
---|
155 | smear_sources = [] |
---|
156 | append_file(file_list=smear_sources, dir_path=smear_dir) |
---|
157 | |
---|
158 | |
---|
159 | package_dir["sans"] = os.path.join("sansmodels", "src", "sans") |
---|
160 | package_dir["sans.models"] = os.path.join("sansmodels", "src", "sans", "models") |
---|
161 | package_dir["sans.models.sans_extension"] = srcdir |
---|
162 | |
---|
163 | package_data['sans.models'] = [os.path.join('media', "*")] |
---|
164 | packages.extend(["sans","sans.models","sans.models.sans_extension"]) |
---|
165 | |
---|
166 | ext_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 |
---|
183 | package_dir["sans.sansview"] = "sansview" |
---|
184 | package_data['sans.sansview'] = ['images/*', 'media/*', 'plugins/*', 'test/*'] |
---|
185 | packages.append("sans.sansview") |
---|
186 | |
---|
187 | required = ['lxml>=2.2.2', 'numpy>=1.4.1', 'matplotlib>=0.99.1.1', 'wxPython>=2.8.11', |
---|
188 | 'pil','periodictable>=1.3.0'] |
---|
189 | if sys.platform=='win32': |
---|
190 | required.extend(['comtypes','pywin32', 'pisa', 'html5lib', 'reportlab']) |
---|
191 | |
---|
192 | # Set up SansView |
---|
193 | setup( |
---|
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 | ) |
---|