[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 |
---|
| 14 | |
---|
[812b901] | 15 | numpy_incl_path = os.path.join(sys.prefix, "Lib", "site-packages", "numpy", "core", "include", "numpy") |
---|
| 16 | |
---|
[42c5acf] | 17 | |
---|
| 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", |
---|
| 82 | version = "0.1", |
---|
| 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", |
---|
[25579e8] | 103 | srcdir+"/SquareWell.c", |
---|
| 104 | "sans/models/c_models/CSquareWellStructure.cpp", |
---|
| 105 | "sans/models/c_models/SquareWell.cpp", |
---|
| 106 | srcdir+"/StickyHS.c", |
---|
| 107 | "sans/models/c_models/CStickyHSStructure.cpp", |
---|
| 108 | "sans/models/c_models/StickyHS.cpp", |
---|
| 109 | srcdir+"/Hardsphere.c", |
---|
| 110 | "sans/models/c_models/CHardsphereStructure.cpp", |
---|
[5be36bb] | 111 | "sans/models/c_models/Hardsphere.cpp", |
---|
[93d04e5] | 112 | srcdir+"/DiamCyl.c", |
---|
| 113 | "sans/models/c_models/CDiamCylFunc.cpp", |
---|
| 114 | "sans/models/c_models/DiamCyl.cpp", |
---|
| 115 | srcdir+"/DiamEllip.c", |
---|
| 116 | "sans/models/c_models/CDiamEllipFunc.cpp", |
---|
[5be36bb] | 117 | "sans/models/c_models/DiamEllip.cpp", |
---|
[25579e8] | 118 | srcdir+"/HayterMSA.c", |
---|
| 119 | "sans/models/c_models/CHayterMSAStructure.cpp", |
---|
[93d04e5] | 120 | "sans/models/c_models/HayterMSA.cpp", |
---|
[0f5bc9f] | 121 | "sans/models/c_models/sphere.cpp", |
---|
[af03ddd] | 122 | #srcdir+"/CCylinderModel.c", |
---|
| 123 | "sans/models/c_models/CCylinderModel.cpp", |
---|
| 124 | "sans/models/c_models/cylinder.cpp", |
---|
| 125 | "sans/models/c_models/parameters.cpp", |
---|
| 126 | "sans/models/c_models/dispersion_visitor.cpp", |
---|
[ae3ce4e] | 127 | srcdir+"/cylinder.c", |
---|
[f41b4c3] | 128 | #srcdir+"/CParallelepiped.c", |
---|
| 129 | "sans/models/c_models/CParallelepipedModel.cpp", |
---|
| 130 | "sans/models/c_models/parallelepiped.cpp", |
---|
| 131 | srcdir+"/parallelepiped.c", |
---|
[0f5bc9f] | 132 | #srcdir+"/CCoreShellCylinderModel.c", |
---|
| 133 | "sans/models/c_models/CCoreShellCylinderModel.cpp", |
---|
| 134 | "sans/models/c_models/coreshellcylinder.cpp", |
---|
[ae3ce4e] | 135 | srcdir+"/core_shell_cylinder.c", |
---|
[27fea3f] | 136 | #srcdir+"/CHollowCylinderModel.c", |
---|
| 137 | "sans/models/c_models/CHollowCylinderModel.cpp", |
---|
| 138 | "sans/models/c_models/hollowcylinder.cpp", |
---|
| 139 | srcdir+"/hollow_cylinder.c", |
---|
[0f5bc9f] | 140 | #srcdir+"/CCoreShellModel.c", |
---|
| 141 | #srcdir+"/core_shell.c", |
---|
| 142 | "sans/models/c_models/CCoreShellModel.cpp", |
---|
| 143 | "sans/models/c_models/coreshellsphere.cpp", |
---|
| 144 | #srcdir+"/CEllipsoidModel.c", |
---|
| 145 | "sans/models/c_models/CEllipsoidModel.cpp", |
---|
| 146 | "sans/models/c_models/ellipsoid.cpp", |
---|
[ae3ce4e] | 147 | srcdir+"/ellipsoid.c", |
---|
[0f5bc9f] | 148 | #srcdir+"/CEllipticalCylinderModel.c", |
---|
| 149 | "sans/models/c_models/CEllipticalCylinderModel.cpp", |
---|
| 150 | "sans/models/c_models/ellipticalcylinder.cpp", |
---|
[ae3ce4e] | 151 | srcdir+"/elliptical_cylinder.c", |
---|
[34c3020] | 152 | #srcdir+"/CTriaxialEllipsoidModel.c", |
---|
[5068697] | 153 | "sans/models/c_models/CTriaxialEllipsoidModel.cpp", |
---|
| 154 | "sans/models/c_models/triaxialellipsoid.cpp", |
---|
| 155 | srcdir+"/triaxial_ellipsoid.c", |
---|
| 156 | #srcdir+"/CFlexibleCylinderModel.c", |
---|
| 157 | "sans/models/c_models/CFlexibleCylinderModel.cpp", |
---|
| 158 | "sans/models/c_models/flexiblecylinder.cpp", |
---|
| 159 | srcdir+"/flexible_cylinder.c", |
---|
| 160 | #srcdir+"/CStakedDisksModel.c", |
---|
| 161 | "sans/models/c_models/CStackedDisksModel.cpp", |
---|
| 162 | "sans/models/c_models/stackeddisks.cpp", |
---|
| 163 | srcdir+"/stacked_disks.c", |
---|
[34c3020] | 164 | #srcdir+"/CLamellarModel.c", |
---|
| 165 | "sans/models/c_models/CLamellarModel.cpp", |
---|
| 166 | "sans/models/c_models/lamellar.cpp", |
---|
| 167 | srcdir+"/lamellar.c", |
---|
| 168 | #srcdir+"/CLamellarFFHGModel.c", |
---|
| 169 | "sans/models/c_models/CLamellarFFHGModel.cpp", |
---|
| 170 | "sans/models/c_models/lamellarFF_HG.cpp", |
---|
| 171 | srcdir+"/lamellarFF_HG.c", |
---|
[27a0771] | 172 | #srcdir+"/CLamellarPSModel.c", |
---|
| 173 | "sans/models/c_models/CLamellarPSModel.cpp", |
---|
| 174 | "sans/models/c_models/lamellarPS.cpp", |
---|
| 175 | srcdir+"/lamellarPS.c", |
---|
| 176 | #srcdir+"/CLamellarPSHGModel.c", |
---|
| 177 | "sans/models/c_models/CLamellarPSHGModel.cpp", |
---|
| 178 | "sans/models/c_models/lamellarPS_HG.cpp", |
---|
| 179 | srcdir+"/lamellarPS_HG.c", |
---|
| 180 | #srcdir+"/COblateModel.c", |
---|
[8e36cdd] | 181 | "sans/models/c_models/CCoreShellEllipsoidModel.cpp", |
---|
[975ec8e] | 182 | "sans/models/c_models/spheroid.cpp", |
---|
| 183 | srcdir+"/spheroid.c", |
---|
| 184 | #srcdir+"/COblateModel.c", |
---|
[5be36bb] | 185 | #"sans/models/c_models/COblateModel.cpp", |
---|
| 186 | #"sans/models/c_models/oblate.cpp", |
---|
| 187 | #srcdir+"/oblate.c", |
---|
[27a0771] | 188 | #srcdir+"/CProlateModel.c", |
---|
[5be36bb] | 189 | #"sans/models/c_models/CProlateModel.cpp", |
---|
| 190 | #"sans/models/c_models/prolate.cpp", |
---|
| 191 | #srcdir+"/prolate.c", |
---|
[3d25331f] | 192 | #srcdir+"/CMultishellModel.c", |
---|
| 193 | "sans/models/c_models/CMultishellModel.cpp", |
---|
| 194 | "sans/models/c_models/multishell.cpp", |
---|
| 195 | srcdir+"/multishell.c", |
---|
| 196 | #srcdir+"/CVesicleModel.c", |
---|
| 197 | "sans/models/c_models/CVesicleModel.cpp", |
---|
| 198 | "sans/models/c_models/vesicle.cpp", |
---|
| 199 | srcdir+"/vesicle.c", |
---|
| 200 | #srcdir+"/CBinaryHSModel.c", |
---|
| 201 | "sans/models/c_models/CBinaryHSModel.cpp", |
---|
| 202 | "sans/models/c_models/binaryHS.cpp", |
---|
| 203 | srcdir+"/binaryHS.c", |
---|
[ae3ce4e] | 204 | srcdir+"/disperser.c", |
---|
| 205 | igordir+"/libCylinder.c", |
---|
[25579e8] | 206 | igordir+"/libStructureFactor.c", |
---|
[ae3ce4e] | 207 | igordir+"/libSphere.c", |
---|
| 208 | srcdir+"/gaussian.c", |
---|
| 209 | srcdir+"/CGaussian.c", |
---|
[f88624d] | 210 | srcdir+"/logNormal.c", |
---|
| 211 | srcdir+"/CLogNormal.c", |
---|
| 212 | srcdir+"/schulz.c", |
---|
| 213 | srcdir+"/CSchulz.c", |
---|
[ae3ce4e] | 214 | srcdir+"/lorentzian.c", |
---|
| 215 | srcdir+"/CLorentzian.c" |
---|
| 216 | ], |
---|
[812b901] | 217 | include_dirs=[igordir,srcdir,"sans/models/c_models",numpy_incl_path])]) |
---|
[ae3ce4e] | 218 | |
---|