1 | """ |
---|
2 | Installation script for SANS models |
---|
3 | |
---|
4 | - To compile and install: |
---|
5 | python setup.py install |
---|
6 | - To create distribution: |
---|
7 | python setup.py bdist_wininst |
---|
8 | - To create odb files: |
---|
9 | python setup.py odb |
---|
10 | |
---|
11 | """ |
---|
12 | import sys |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | def createODBcontent(class_name): |
---|
18 | """ |
---|
19 | Return the content of the Pyre odb file for a given class |
---|
20 | @param class_name: Name of the class to write an odb file for [string] |
---|
21 | @return: content of the file [string] |
---|
22 | """ |
---|
23 | content = "\"\"\"\n" |
---|
24 | content += " Facility for SANS model\n\n" |
---|
25 | content += " WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n" |
---|
26 | content += " DO NOT MODIFY\n\n" |
---|
27 | content += " This code was written as part of the DANSE project\n" |
---|
28 | content += " http://danse.us/trac/sans/\n" |
---|
29 | content += " @copyright 2007:" |
---|
30 | content += " SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n" |
---|
31 | content += "\"\"\"\n" |
---|
32 | content += "def model():\n" |
---|
33 | content += " from ScatteringIntensityFactory import ScatteringIntensityFactory\n" |
---|
34 | content += " from sans.models.%s import %s\n" % (class_name, class_name) |
---|
35 | content += " return ScatteringIntensityFactory(%s)('%s')\n"\ |
---|
36 | % (class_name, class_name) |
---|
37 | |
---|
38 | return content |
---|
39 | |
---|
40 | def createODBfiles(): |
---|
41 | """ |
---|
42 | Create odb files for all available models |
---|
43 | """ |
---|
44 | from sans.models.ModelFactory import ModelFactory |
---|
45 | |
---|
46 | class_list = ModelFactory().getAllModels() |
---|
47 | for name in class_list: |
---|
48 | odb = open("sans/models/pyre/%s.odb" % name, 'w') |
---|
49 | odb.write(createODBcontent(name)) |
---|
50 | odb.close() |
---|
51 | print "sans/models/pyre/%s.odb created" % name |
---|
52 | |
---|
53 | # |
---|
54 | # Proceed with installation |
---|
55 | # |
---|
56 | |
---|
57 | # First, create the odb files |
---|
58 | if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb': |
---|
59 | print "Creating odb files" |
---|
60 | try: |
---|
61 | createODBfiles() |
---|
62 | except: |
---|
63 | print "ERROR: could not create odb files" |
---|
64 | print sys.exc_value |
---|
65 | sys.exit() |
---|
66 | |
---|
67 | # Then build and install the modules |
---|
68 | from distutils.core import setup, Extension |
---|
69 | |
---|
70 | |
---|
71 | # Build the module name |
---|
72 | srcdir = "sans/models/c_extensions" |
---|
73 | igordir = "libigor" |
---|
74 | |
---|
75 | print "Installing SANS models" |
---|
76 | |
---|
77 | |
---|
78 | setup( |
---|
79 | name="models", |
---|
80 | version = "0.1", |
---|
81 | description = "Python module for SANS scattering models", |
---|
82 | author = "Mathieu Doucet", |
---|
83 | author_email = "doucet@nist.gov", |
---|
84 | url = "http://danse.us/trac/sans", |
---|
85 | |
---|
86 | # Place this module under the sans package |
---|
87 | #ext_package = "sans", |
---|
88 | |
---|
89 | # Use the pure python modules |
---|
90 | package_dir = {"sans_extension":"sans/models/c_extensions"}, |
---|
91 | |
---|
92 | packages = ["sans","sans.models","sans.models.test", |
---|
93 | "sans_extension","sans.models.pyre"], |
---|
94 | |
---|
95 | ext_modules = [ Extension("sans_extension.c_models", |
---|
96 | sources = [ |
---|
97 | "sans/models/c_models/c_models.cpp", |
---|
98 | #srcdir+"/CSphereModel.c", |
---|
99 | #srcdir+"/sphere.c", |
---|
100 | "sans/models/c_models/CSphereModel.cpp", |
---|
101 | srcdir+"/SquareWell.c", |
---|
102 | "sans/models/c_models/CSquareWellStructure.cpp", |
---|
103 | "sans/models/c_models/SquareWell.cpp", |
---|
104 | srcdir+"/StickyHS.c", |
---|
105 | "sans/models/c_models/CStickyHSStructure.cpp", |
---|
106 | "sans/models/c_models/StickyHS.cpp", |
---|
107 | srcdir+"/Hardsphere.c", |
---|
108 | "sans/models/c_models/CHardsphereStructure.cpp", |
---|
109 | "sans/models/c_models/Hardsphere.cpp", |
---|
110 | srcdir+"/DiamCyl.c", |
---|
111 | "sans/models/c_models/CDiamCylFunc.cpp", |
---|
112 | "sans/models/c_models/DiamCyl.cpp", |
---|
113 | srcdir+"/DiamEllip.c", |
---|
114 | "sans/models/c_models/CDiamEllipFunc.cpp", |
---|
115 | "sans/models/c_models/DiamEllip.cpp", |
---|
116 | srcdir+"/HayterMSA.c", |
---|
117 | "sans/models/c_models/CHayterMSAStructure.cpp", |
---|
118 | "sans/models/c_models/HayterMSA.cpp", |
---|
119 | "sans/models/c_models/sphere.cpp", |
---|
120 | #srcdir+"/CCylinderModel.c", |
---|
121 | "sans/models/c_models/CCylinderModel.cpp", |
---|
122 | "sans/models/c_models/cylinder.cpp", |
---|
123 | "sans/models/c_models/parameters.cpp", |
---|
124 | "sans/models/c_models/dispersion_visitor.cpp", |
---|
125 | srcdir+"/cylinder.c", |
---|
126 | #srcdir+"/CParallelepiped.c", |
---|
127 | "sans/models/c_models/CParallelepipedModel.cpp", |
---|
128 | "sans/models/c_models/parallelepiped.cpp", |
---|
129 | srcdir+"/parallelepiped.c", |
---|
130 | #srcdir+"/CCoreShellCylinderModel.c", |
---|
131 | "sans/models/c_models/CCoreShellCylinderModel.cpp", |
---|
132 | "sans/models/c_models/coreshellcylinder.cpp", |
---|
133 | srcdir+"/core_shell_cylinder.c", |
---|
134 | #srcdir+"/CHollowCylinderModel.c", |
---|
135 | "sans/models/c_models/CHollowCylinderModel.cpp", |
---|
136 | "sans/models/c_models/hollowcylinder.cpp", |
---|
137 | srcdir+"/hollow_cylinder.c", |
---|
138 | #srcdir+"/CCoreShellModel.c", |
---|
139 | #srcdir+"/core_shell.c", |
---|
140 | "sans/models/c_models/CCoreShellModel.cpp", |
---|
141 | "sans/models/c_models/coreshellsphere.cpp", |
---|
142 | #srcdir+"/CEllipsoidModel.c", |
---|
143 | "sans/models/c_models/CEllipsoidModel.cpp", |
---|
144 | "sans/models/c_models/ellipsoid.cpp", |
---|
145 | srcdir+"/ellipsoid.c", |
---|
146 | #srcdir+"/CEllipticalCylinderModel.c", |
---|
147 | "sans/models/c_models/CEllipticalCylinderModel.cpp", |
---|
148 | "sans/models/c_models/ellipticalcylinder.cpp", |
---|
149 | srcdir+"/elliptical_cylinder.c", |
---|
150 | #srcdir+"/CTriaxialEllipsoidModel.c", |
---|
151 | "sans/models/c_models/CTriaxialEllipsoidModel.cpp", |
---|
152 | "sans/models/c_models/triaxialellipsoid.cpp", |
---|
153 | srcdir+"/triaxial_ellipsoid.c", |
---|
154 | #srcdir+"/CFlexibleCylinderModel.c", |
---|
155 | "sans/models/c_models/CFlexibleCylinderModel.cpp", |
---|
156 | "sans/models/c_models/flexiblecylinder.cpp", |
---|
157 | srcdir+"/flexible_cylinder.c", |
---|
158 | #srcdir+"/CStakedDisksModel.c", |
---|
159 | "sans/models/c_models/CStackedDisksModel.cpp", |
---|
160 | "sans/models/c_models/stackeddisks.cpp", |
---|
161 | srcdir+"/stacked_disks.c", |
---|
162 | #srcdir+"/CLamellarModel.c", |
---|
163 | "sans/models/c_models/CLamellarModel.cpp", |
---|
164 | "sans/models/c_models/lamellar.cpp", |
---|
165 | srcdir+"/lamellar.c", |
---|
166 | #srcdir+"/CLamellarFFHGModel.c", |
---|
167 | "sans/models/c_models/CLamellarFFHGModel.cpp", |
---|
168 | "sans/models/c_models/lamellarFF_HG.cpp", |
---|
169 | srcdir+"/lamellarFF_HG.c", |
---|
170 | #srcdir+"/CLamellarPSModel.c", |
---|
171 | "sans/models/c_models/CLamellarPSModel.cpp", |
---|
172 | "sans/models/c_models/lamellarPS.cpp", |
---|
173 | srcdir+"/lamellarPS.c", |
---|
174 | #srcdir+"/CLamellarPSHGModel.c", |
---|
175 | "sans/models/c_models/CLamellarPSHGModel.cpp", |
---|
176 | "sans/models/c_models/lamellarPS_HG.cpp", |
---|
177 | srcdir+"/lamellarPS_HG.c", |
---|
178 | #srcdir+"/COblateModel.c", |
---|
179 | "sans/models/c_models/COblateModel.cpp", |
---|
180 | "sans/models/c_models/oblate.cpp", |
---|
181 | srcdir+"/oblate.c", |
---|
182 | #srcdir+"/CProlateModel.c", |
---|
183 | "sans/models/c_models/CProlateModel.cpp", |
---|
184 | "sans/models/c_models/prolate.cpp", |
---|
185 | srcdir+"/prolate.c", |
---|
186 | #srcdir+"/CMultishellModel.c", |
---|
187 | "sans/models/c_models/CMultishellModel.cpp", |
---|
188 | "sans/models/c_models/multishell.cpp", |
---|
189 | srcdir+"/multishell.c", |
---|
190 | #srcdir+"/CVesicleModel.c", |
---|
191 | "sans/models/c_models/CVesicleModel.cpp", |
---|
192 | "sans/models/c_models/vesicle.cpp", |
---|
193 | srcdir+"/vesicle.c", |
---|
194 | #srcdir+"/CBinaryHSModel.c", |
---|
195 | "sans/models/c_models/CBinaryHSModel.cpp", |
---|
196 | "sans/models/c_models/binaryHS.cpp", |
---|
197 | srcdir+"/binaryHS.c", |
---|
198 | srcdir+"/disperser.c", |
---|
199 | igordir+"/libCylinder.c", |
---|
200 | igordir+"/libStructureFactor.c", |
---|
201 | igordir+"/libSphere.c", |
---|
202 | srcdir+"/gaussian.c", |
---|
203 | srcdir+"/CGaussian.c", |
---|
204 | srcdir+"/lorentzian.c", |
---|
205 | srcdir+"/CLorentzian.c" |
---|
206 | ], |
---|
207 | include_dirs=[igordir,srcdir,"sans/models/c_models"])]) |
---|
208 | |
---|