[ae3ce4e] | 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 | """ |
---|
[f88624d] | 12 | import sys |
---|
| 13 | import os |
---|
[87615a48] | 14 | |
---|
[b72b595] | 15 | from numpy.distutils.misc_util import get_numpy_include_dirs |
---|
[6c13861] | 16 | numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy") |
---|
[b72b595] | 17 | |
---|
[ae3ce4e] | 18 | def createODBcontent(class_name): |
---|
| 19 | """ |
---|
| 20 | Return the content of the Pyre odb file for a given class |
---|
| 21 | @param class_name: Name of the class to write an odb file for [string] |
---|
| 22 | @return: content of the file [string] |
---|
| 23 | """ |
---|
| 24 | content = "\"\"\"\n" |
---|
| 25 | content += " Facility for SANS model\n\n" |
---|
| 26 | content += " WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n" |
---|
| 27 | content += " DO NOT MODIFY\n\n" |
---|
| 28 | content += " This code was written as part of the DANSE project\n" |
---|
| 29 | content += " http://danse.us/trac/sans/\n" |
---|
| 30 | content += " @copyright 2007:" |
---|
[25579e8] | 31 | content += " SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n" |
---|
[ae3ce4e] | 32 | content += "\"\"\"\n" |
---|
| 33 | content += "def model():\n" |
---|
| 34 | content += " from ScatteringIntensityFactory import ScatteringIntensityFactory\n" |
---|
| 35 | content += " from sans.models.%s import %s\n" % (class_name, class_name) |
---|
| 36 | content += " return ScatteringIntensityFactory(%s)('%s')\n"\ |
---|
| 37 | % (class_name, class_name) |
---|
| 38 | |
---|
| 39 | return content |
---|
| 40 | |
---|
| 41 | def createODBfiles(): |
---|
| 42 | """ |
---|
| 43 | Create odb files for all available models |
---|
| 44 | """ |
---|
| 45 | from sans.models.ModelFactory import ModelFactory |
---|
| 46 | |
---|
| 47 | class_list = ModelFactory().getAllModels() |
---|
| 48 | for name in class_list: |
---|
| 49 | odb = open("sans/models/pyre/%s.odb" % name, 'w') |
---|
| 50 | odb.write(createODBcontent(name)) |
---|
| 51 | odb.close() |
---|
| 52 | print "sans/models/pyre/%s.odb created" % name |
---|
| 53 | |
---|
| 54 | # |
---|
| 55 | # Proceed with installation |
---|
| 56 | # |
---|
| 57 | |
---|
| 58 | # First, create the odb files |
---|
| 59 | if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb': |
---|
| 60 | print "Creating odb files" |
---|
| 61 | try: |
---|
| 62 | createODBfiles() |
---|
| 63 | except: |
---|
| 64 | print "ERROR: could not create odb files" |
---|
| 65 | print sys.exc_value |
---|
| 66 | sys.exit() |
---|
| 67 | |
---|
| 68 | # Then build and install the modules |
---|
[87615a48] | 69 | from distutils.core import Extension, setup |
---|
| 70 | #from setuptools import setup#, find_packages |
---|
[ae3ce4e] | 71 | |
---|
| 72 | # Build the module name |
---|
| 73 | srcdir = "sans/models/c_extensions" |
---|
| 74 | igordir = "libigor" |
---|
| 75 | |
---|
| 76 | print "Installing SANS models" |
---|
| 77 | |
---|
| 78 | |
---|
[87615a48] | 79 | dist = setup( |
---|
[ae3ce4e] | 80 | name="models", |
---|
[87615a48] | 81 | version = "0.9.1", |
---|
[ae3ce4e] | 82 | description = "Python module for SANS scattering models", |
---|
[87615a48] | 83 | author = "SANS/DANSE", |
---|
| 84 | author_email = "sansdanse@gmail.gov", |
---|
[ae3ce4e] | 85 | url = "http://danse.us/trac/sans", |
---|
| 86 | |
---|
| 87 | # Place this module under the sans package |
---|
| 88 | #ext_package = "sans", |
---|
| 89 | |
---|
| 90 | # Use the pure python modules |
---|
[e715e4f] | 91 | package_dir = {"sans_extension":"sans/models/c_extensions", |
---|
| 92 | "sans.models.media":"media"}, |
---|
[87615a48] | 93 | package_data={'sans.models.media': ['*.gif','*.jpg','*.png','*.html']}, |
---|
[ae3ce4e] | 94 | packages = ["sans","sans.models","sans.models.test", |
---|
[e715e4f] | 95 | "sans_extension","sans.models.pyre", |
---|
| 96 | "sans.models.media"], |
---|
[ae3ce4e] | 97 | |
---|
| 98 | ext_modules = [ Extension("sans_extension.c_models", |
---|
| 99 | sources = [ |
---|
[8809e48] | 100 | "sans/models/c_models/c_models.cpp", |
---|
[0f5bc9f] | 101 | #srcdir+"/CSphereModel.c", |
---|
| 102 | #srcdir+"/sphere.c", |
---|
| 103 | "sans/models/c_models/CSphereModel.cpp", |
---|
[ca153ba] | 104 | "sans/models/c_models/CPearlNecklaceModel.cpp", |
---|
| 105 | "sans/models/c_models/pearlnecklace.cpp", |
---|
| 106 | srcdir+"/pearlnecklace.c", |
---|
[5d57267] | 107 | "sans/models/c_models/COnionModel.cpp", |
---|
| 108 | "sans/models/c_models/onion.cpp", |
---|
| 109 | srcdir+"/onion.c", |
---|
[35aface] | 110 | "sans/models/c_models/CReflModel.cpp", |
---|
| 111 | "sans/models/c_models/refl.cpp", |
---|
| 112 | srcdir+"/refl.c", |
---|
[3be060d] | 113 | "sans/models/c_models/CReflAdvModel.cpp", |
---|
| 114 | "sans/models/c_models/refl_adv.cpp", |
---|
| 115 | srcdir+"/refl_adv.c", |
---|
[8240eab] | 116 | #srcdir+"/SquareWell.c", |
---|
[25579e8] | 117 | "sans/models/c_models/CSquareWellStructure.cpp", |
---|
| 118 | "sans/models/c_models/SquareWell.cpp", |
---|
[8240eab] | 119 | #srcdir+"/StickyHS.c", |
---|
[25579e8] | 120 | "sans/models/c_models/CStickyHSStructure.cpp", |
---|
[8240eab] | 121 | "sans/models/c_models/StickyHS.cpp", |
---|
[25579e8] | 122 | "sans/models/c_models/CHardsphereStructure.cpp", |
---|
[5be36bb] | 123 | "sans/models/c_models/Hardsphere.cpp", |
---|
[8240eab] | 124 | #srcdir+"/DiamCyl.c", |
---|
[93d04e5] | 125 | "sans/models/c_models/CDiamCylFunc.cpp", |
---|
| 126 | "sans/models/c_models/DiamCyl.cpp", |
---|
[8240eab] | 127 | #srcdir+"/DiamEllip.c", |
---|
[93d04e5] | 128 | "sans/models/c_models/CDiamEllipFunc.cpp", |
---|
[5be36bb] | 129 | "sans/models/c_models/DiamEllip.cpp", |
---|
[8240eab] | 130 | #srcdir+"/HayterMSA.c", |
---|
[25579e8] | 131 | "sans/models/c_models/CHayterMSAStructure.cpp", |
---|
[93d04e5] | 132 | "sans/models/c_models/HayterMSA.cpp", |
---|
[0f5bc9f] | 133 | "sans/models/c_models/sphere.cpp", |
---|
[89c0919] | 134 | srcdir+"/fuzzysphere.c", |
---|
| 135 | "sans/models/c_models/CFuzzySphereModel.cpp", |
---|
| 136 | "sans/models/c_models/fuzzysphere.cpp", |
---|
[af03ddd] | 137 | #srcdir+"/CCylinderModel.c", |
---|
| 138 | "sans/models/c_models/CCylinderModel.cpp", |
---|
| 139 | "sans/models/c_models/cylinder.cpp", |
---|
| 140 | "sans/models/c_models/parameters.cpp", |
---|
| 141 | "sans/models/c_models/dispersion_visitor.cpp", |
---|
[ae3ce4e] | 142 | srcdir+"/cylinder.c", |
---|
[f41b4c3] | 143 | #srcdir+"/CParallelepiped.c", |
---|
| 144 | "sans/models/c_models/CParallelepipedModel.cpp", |
---|
| 145 | "sans/models/c_models/parallelepiped.cpp", |
---|
| 146 | srcdir+"/parallelepiped.c", |
---|
[2e862a0] | 147 | "sans/models/c_models/CCSParallelepipedModel.cpp", |
---|
| 148 | "sans/models/c_models/csparallelepiped.cpp", |
---|
| 149 | srcdir+"/csparallelepiped.c", |
---|
[0f5bc9f] | 150 | #srcdir+"/CCoreShellCylinderModel.c", |
---|
| 151 | "sans/models/c_models/CCoreShellCylinderModel.cpp", |
---|
| 152 | "sans/models/c_models/coreshellcylinder.cpp", |
---|
[ae3ce4e] | 153 | srcdir+"/core_shell_cylinder.c", |
---|
[27fea3f] | 154 | #srcdir+"/CHollowCylinderModel.c", |
---|
| 155 | "sans/models/c_models/CHollowCylinderModel.cpp", |
---|
| 156 | "sans/models/c_models/hollowcylinder.cpp", |
---|
| 157 | srcdir+"/hollow_cylinder.c", |
---|
[0f5bc9f] | 158 | #srcdir+"/CCoreShellModel.c", |
---|
| 159 | #srcdir+"/core_shell.c", |
---|
| 160 | "sans/models/c_models/CCoreShellModel.cpp", |
---|
| 161 | "sans/models/c_models/coreshellsphere.cpp", |
---|
| 162 | #srcdir+"/CEllipsoidModel.c", |
---|
| 163 | "sans/models/c_models/CEllipsoidModel.cpp", |
---|
| 164 | "sans/models/c_models/ellipsoid.cpp", |
---|
[ae3ce4e] | 165 | srcdir+"/ellipsoid.c", |
---|
[89c0919] | 166 | "sans/models/c_models/CCoreFourShellModel.cpp", |
---|
| 167 | "sans/models/c_models/corefourshell.cpp", |
---|
[2399b2a] | 168 | #srcdir+"/corefourshell.c", |
---|
[0f5bc9f] | 169 | #srcdir+"/CEllipticalCylinderModel.c", |
---|
| 170 | "sans/models/c_models/CEllipticalCylinderModel.cpp", |
---|
| 171 | "sans/models/c_models/ellipticalcylinder.cpp", |
---|
[ae3ce4e] | 172 | srcdir+"/elliptical_cylinder.c", |
---|
[34c3020] | 173 | #srcdir+"/CTriaxialEllipsoidModel.c", |
---|
[5068697] | 174 | "sans/models/c_models/CTriaxialEllipsoidModel.cpp", |
---|
| 175 | "sans/models/c_models/triaxialellipsoid.cpp", |
---|
| 176 | srcdir+"/triaxial_ellipsoid.c", |
---|
| 177 | #srcdir+"/CFlexibleCylinderModel.c", |
---|
| 178 | "sans/models/c_models/CFlexibleCylinderModel.cpp", |
---|
| 179 | "sans/models/c_models/flexiblecylinder.cpp", |
---|
| 180 | srcdir+"/flexible_cylinder.c", |
---|
[89c0919] | 181 | "sans/models/c_models/CFlexCylEllipXModel.cpp", |
---|
| 182 | "sans/models/c_models/flexcyl_ellipX.cpp", |
---|
| 183 | srcdir+"/flexcyl_ellipX.c", |
---|
[20f00bed] | 184 | "sans/models/c_models/CBarBellModel.cpp", |
---|
| 185 | "sans/models/c_models/barbell.cpp", |
---|
| 186 | srcdir+"/barbell.c", |
---|
| 187 | "sans/models/c_models/CCappedCylinderModel.cpp", |
---|
| 188 | "sans/models/c_models/capcyl.cpp", |
---|
| 189 | srcdir+"/capcyl.c", |
---|
[5068697] | 190 | #srcdir+"/CStakedDisksModel.c", |
---|
[d2d815d] | 191 | "sans/models/c_models/CSCCrystalModel.cpp", |
---|
| 192 | "sans/models/c_models/sc.cpp", |
---|
| 193 | srcdir+"/sc.c", |
---|
| 194 | "sans/models/c_models/CFCCrystalModel.cpp", |
---|
| 195 | "sans/models/c_models/fcc.cpp", |
---|
| 196 | srcdir+"/fcc.c", |
---|
| 197 | "sans/models/c_models/CBCCrystalModel.cpp", |
---|
| 198 | "sans/models/c_models/bcc.cpp", |
---|
| 199 | srcdir+"/bcc.c", |
---|
[5068697] | 200 | "sans/models/c_models/CStackedDisksModel.cpp", |
---|
| 201 | "sans/models/c_models/stackeddisks.cpp", |
---|
| 202 | srcdir+"/stacked_disks.c", |
---|
[34c3020] | 203 | #srcdir+"/CLamellarModel.c", |
---|
| 204 | "sans/models/c_models/CLamellarModel.cpp", |
---|
| 205 | "sans/models/c_models/lamellar.cpp", |
---|
| 206 | srcdir+"/lamellar.c", |
---|
| 207 | #srcdir+"/CLamellarFFHGModel.c", |
---|
| 208 | "sans/models/c_models/CLamellarFFHGModel.cpp", |
---|
| 209 | "sans/models/c_models/lamellarFF_HG.cpp", |
---|
[2399b2a] | 210 | #srcdir+"/lamellarFF_HG.c", |
---|
[27a0771] | 211 | #srcdir+"/CLamellarPSModel.c", |
---|
| 212 | "sans/models/c_models/CLamellarPSModel.cpp", |
---|
| 213 | "sans/models/c_models/lamellarPS.cpp", |
---|
| 214 | srcdir+"/lamellarPS.c", |
---|
| 215 | #srcdir+"/CLamellarPSHGModel.c", |
---|
| 216 | "sans/models/c_models/CLamellarPSHGModel.cpp", |
---|
| 217 | "sans/models/c_models/lamellarPS_HG.cpp", |
---|
[2399b2a] | 218 | #srcdir+"/lamellarPS_HG.c", |
---|
[20f00bed] | 219 | "sans/models/c_models/CLamellarPCrystalModel.cpp", |
---|
| 220 | "sans/models/c_models/lamellarPC.cpp", |
---|
[2399b2a] | 221 | #srcdir+"/lamellarPC.c", |
---|
[27a0771] | 222 | #srcdir+"/COblateModel.c", |
---|
[8e36cdd] | 223 | "sans/models/c_models/CCoreShellEllipsoidModel.cpp", |
---|
[975ec8e] | 224 | "sans/models/c_models/spheroid.cpp", |
---|
| 225 | srcdir+"/spheroid.c", |
---|
| 226 | #srcdir+"/COblateModel.c", |
---|
[5be36bb] | 227 | #"sans/models/c_models/COblateModel.cpp", |
---|
| 228 | #"sans/models/c_models/oblate.cpp", |
---|
| 229 | #srcdir+"/oblate.c", |
---|
[27a0771] | 230 | #srcdir+"/CProlateModel.c", |
---|
[5be36bb] | 231 | #"sans/models/c_models/CProlateModel.cpp", |
---|
| 232 | #"sans/models/c_models/prolate.cpp", |
---|
| 233 | #srcdir+"/prolate.c", |
---|
[3d25331f] | 234 | #srcdir+"/CMultishellModel.c", |
---|
[0211d67] | 235 | "sans/models/c_models/CMultiShellModel.cpp", |
---|
[3d25331f] | 236 | "sans/models/c_models/multishell.cpp", |
---|
[2399b2a] | 237 | #srcdir+"/multishell.c", |
---|
[96d19c6] | 238 | "sans/models/c_models/CSphereSLDModel.cpp", |
---|
| 239 | "sans/models/c_models/spheresld.cpp", |
---|
| 240 | srcdir+"/spheresld.c", |
---|
[3d25331f] | 241 | #srcdir+"/CVesicleModel.c", |
---|
| 242 | "sans/models/c_models/CVesicleModel.cpp", |
---|
| 243 | "sans/models/c_models/vesicle.cpp", |
---|
[2399b2a] | 244 | #srcdir+"/vesicle.c", |
---|
[3d25331f] | 245 | #srcdir+"/CBinaryHSModel.c", |
---|
| 246 | "sans/models/c_models/CBinaryHSModel.cpp", |
---|
| 247 | "sans/models/c_models/binaryHS.cpp", |
---|
[89c0919] | 248 | "sans/models/c_models/CPoly_GaussCoil.cpp", |
---|
| 249 | "sans/models/c_models/polygausscoil.cpp", |
---|
[35aface] | 250 | srcdir+"/rpa.c", |
---|
| 251 | "sans/models/c_models/CRPAModel.cpp", |
---|
| 252 | "sans/models/c_models/rpa.cpp", |
---|
[2399b2a] | 253 | #srcdir+"/fractal.c", |
---|
[89c0919] | 254 | "sans/models/c_models/CFractalModel.cpp", |
---|
| 255 | "sans/models/c_models/fractal.cpp", |
---|
[96d19c6] | 256 | srcdir+"/sld_cal.c", |
---|
| 257 | "sans/models/c_models/CSLDCalFunc.cpp", |
---|
| 258 | "sans/models/c_models/sld_cal.cpp", |
---|
[89c0919] | 259 | #gammainc function need to imported from somewhere |
---|
| 260 | #srcdir+"/polyexclvol.c", |
---|
| 261 | #"sans/models/c_models/CPolymerExclVolModel.cpp", |
---|
| 262 | #"sans/models/c_models/polyexclvol.cpp", |
---|
[96d19c6] | 263 | srcdir+"/libmultifunc/librefl.c", |
---|
[ca153ba] | 264 | srcdir+"/libmultifunc/libfunc.c", |
---|
[8240eab] | 265 | #srcdir+"/polygausscoil.c", |
---|
[2399b2a] | 266 | #srcdir+"/binaryHS.c", |
---|
[59b9b675] | 267 | srcdir+"/disperser.c", |
---|
[ae3ce4e] | 268 | igordir+"/libCylinder.c", |
---|
[25579e8] | 269 | igordir+"/libStructureFactor.c", |
---|
[ae3ce4e] | 270 | igordir+"/libSphere.c", |
---|
[89c0919] | 271 | igordir+"/libTwoPhase.c", |
---|
[59b9b675] | 272 | srcdir+"/gaussian.c", |
---|
| 273 | srcdir+"/CGaussian.c", |
---|
| 274 | srcdir+"/logNormal.c", |
---|
| 275 | srcdir+"/CLogNormal.c", |
---|
| 276 | srcdir+"/schulz.c", |
---|
| 277 | srcdir+"/CSchulz.c", |
---|
| 278 | srcdir+"/lorentzian.c", |
---|
| 279 | srcdir+"/CLorentzian.c" |
---|
[ae3ce4e] | 280 | ], |
---|
[87615a48] | 281 | include_dirs=[igordir,srcdir,"sans/models/c_models",numpy_incl_path]), |
---|
| 282 | # Smearer extension |
---|
| 283 | Extension("sans_extension.smearer", |
---|
[642b259] | 284 | sources = [ |
---|
| 285 | "sans/models/c_smearer/smearer_module.cpp", |
---|
| 286 | "sans/models/c_smearer/smearer.cpp", |
---|
| 287 | ], |
---|
[87615a48] | 288 | include_dirs=["sans/models/c_smearer",numpy_incl_path]), |
---|
| 289 | Extension("sans_extension.smearer2d_helper", |
---|
| 290 | sources = [ |
---|
| 291 | "sans/models/c_smearer/smearer2d_helper_module.cpp", |
---|
| 292 | "sans/models/c_smearer/smearer2d_helper.cpp", |
---|
| 293 | ], |
---|
| 294 | include_dirs=["sans/models/c_smearer",numpy_incl_path] |
---|
| 295 | ) |
---|
| 296 | ] |
---|
| 297 | ) |
---|
[b72b595] | 298 | |
---|