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