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