[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 | """ |
---|
[dce738a] | 12 | import sys,os |
---|
[6d61373] | 13 | |
---|
[812b901] | 14 | numpy_incl_path = os.path.join(sys.prefix, "Lib", "site-packages", "numpy", "core", "include", "numpy") |
---|
| 15 | |
---|
[42c5acf] | 16 | |
---|
| 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 |
---|
| 69 | from distutils.core import setup, Extension |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | # Build the module name |
---|
| 73 | srcdir = "sans/models/c_extensions" |
---|
| 74 | igordir = "libigor" |
---|
| 75 | |
---|
| 76 | print "Installing SANS models" |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | setup( |
---|
| 80 | name="models", |
---|
| 81 | version = "0.1", |
---|
| 82 | description = "Python module for SANS scattering models", |
---|
| 83 | author = "Mathieu Doucet", |
---|
| 84 | author_email = "doucet@nist.gov", |
---|
| 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 |
---|
| 91 | package_dir = {"sans_extension":"sans/models/c_extensions"}, |
---|
| 92 | |
---|
| 93 | packages = ["sans","sans.models","sans.models.test", |
---|
| 94 | "sans_extension","sans.models.pyre"], |
---|
| 95 | |
---|
| 96 | ext_modules = [ Extension("sans_extension.c_models", |
---|
| 97 | sources = [ |
---|
[8809e48] | 98 | "sans/models/c_models/c_models.cpp", |
---|
[0f5bc9f] | 99 | #srcdir+"/CSphereModel.c", |
---|
| 100 | #srcdir+"/sphere.c", |
---|
| 101 | "sans/models/c_models/CSphereModel.cpp", |
---|
[25579e8] | 102 | srcdir+"/SquareWell.c", |
---|
| 103 | "sans/models/c_models/CSquareWellStructure.cpp", |
---|
| 104 | "sans/models/c_models/SquareWell.cpp", |
---|
| 105 | srcdir+"/StickyHS.c", |
---|
| 106 | "sans/models/c_models/CStickyHSStructure.cpp", |
---|
| 107 | "sans/models/c_models/StickyHS.cpp", |
---|
| 108 | srcdir+"/Hardsphere.c", |
---|
| 109 | "sans/models/c_models/CHardsphereStructure.cpp", |
---|
| 110 | "sans/models/c_models/Hardsphere.cpp", |
---|
[93d04e5] | 111 | srcdir+"/DiamCyl.c", |
---|
| 112 | "sans/models/c_models/CDiamCylFunc.cpp", |
---|
| 113 | "sans/models/c_models/DiamCyl.cpp", |
---|
| 114 | srcdir+"/DiamEllip.c", |
---|
| 115 | "sans/models/c_models/CDiamEllipFunc.cpp", |
---|
| 116 | "sans/models/c_models/DiamEllip.cpp", |
---|
[25579e8] | 117 | srcdir+"/HayterMSA.c", |
---|
| 118 | "sans/models/c_models/CHayterMSAStructure.cpp", |
---|
[93d04e5] | 119 | "sans/models/c_models/HayterMSA.cpp", |
---|
[0f5bc9f] | 120 | "sans/models/c_models/sphere.cpp", |
---|
[af03ddd] | 121 | #srcdir+"/CCylinderModel.c", |
---|
| 122 | "sans/models/c_models/CCylinderModel.cpp", |
---|
| 123 | "sans/models/c_models/cylinder.cpp", |
---|
| 124 | "sans/models/c_models/parameters.cpp", |
---|
| 125 | "sans/models/c_models/dispersion_visitor.cpp", |
---|
[ae3ce4e] | 126 | srcdir+"/cylinder.c", |
---|
[f41b4c3] | 127 | #srcdir+"/CParallelepiped.c", |
---|
| 128 | "sans/models/c_models/CParallelepipedModel.cpp", |
---|
| 129 | "sans/models/c_models/parallelepiped.cpp", |
---|
| 130 | srcdir+"/parallelepiped.c", |
---|
[0f5bc9f] | 131 | #srcdir+"/CCoreShellCylinderModel.c", |
---|
| 132 | "sans/models/c_models/CCoreShellCylinderModel.cpp", |
---|
| 133 | "sans/models/c_models/coreshellcylinder.cpp", |
---|
[ae3ce4e] | 134 | srcdir+"/core_shell_cylinder.c", |
---|
[27fea3f] | 135 | #srcdir+"/CHollowCylinderModel.c", |
---|
| 136 | "sans/models/c_models/CHollowCylinderModel.cpp", |
---|
| 137 | "sans/models/c_models/hollowcylinder.cpp", |
---|
| 138 | srcdir+"/hollow_cylinder.c", |
---|
[0f5bc9f] | 139 | #srcdir+"/CCoreShellModel.c", |
---|
| 140 | #srcdir+"/core_shell.c", |
---|
| 141 | "sans/models/c_models/CCoreShellModel.cpp", |
---|
| 142 | "sans/models/c_models/coreshellsphere.cpp", |
---|
| 143 | #srcdir+"/CEllipsoidModel.c", |
---|
| 144 | "sans/models/c_models/CEllipsoidModel.cpp", |
---|
| 145 | "sans/models/c_models/ellipsoid.cpp", |
---|
[ae3ce4e] | 146 | srcdir+"/ellipsoid.c", |
---|
[0f5bc9f] | 147 | #srcdir+"/CEllipticalCylinderModel.c", |
---|
| 148 | "sans/models/c_models/CEllipticalCylinderModel.cpp", |
---|
| 149 | "sans/models/c_models/ellipticalcylinder.cpp", |
---|
[ae3ce4e] | 150 | srcdir+"/elliptical_cylinder.c", |
---|
[34c3020] | 151 | #srcdir+"/CTriaxialEllipsoidModel.c", |
---|
[5068697] | 152 | "sans/models/c_models/CTriaxialEllipsoidModel.cpp", |
---|
| 153 | "sans/models/c_models/triaxialellipsoid.cpp", |
---|
| 154 | srcdir+"/triaxial_ellipsoid.c", |
---|
| 155 | #srcdir+"/CFlexibleCylinderModel.c", |
---|
| 156 | "sans/models/c_models/CFlexibleCylinderModel.cpp", |
---|
| 157 | "sans/models/c_models/flexiblecylinder.cpp", |
---|
| 158 | srcdir+"/flexible_cylinder.c", |
---|
| 159 | #srcdir+"/CStakedDisksModel.c", |
---|
| 160 | "sans/models/c_models/CStackedDisksModel.cpp", |
---|
| 161 | "sans/models/c_models/stackeddisks.cpp", |
---|
| 162 | srcdir+"/stacked_disks.c", |
---|
[34c3020] | 163 | #srcdir+"/CLamellarModel.c", |
---|
| 164 | "sans/models/c_models/CLamellarModel.cpp", |
---|
| 165 | "sans/models/c_models/lamellar.cpp", |
---|
| 166 | srcdir+"/lamellar.c", |
---|
| 167 | #srcdir+"/CLamellarFFHGModel.c", |
---|
| 168 | "sans/models/c_models/CLamellarFFHGModel.cpp", |
---|
| 169 | "sans/models/c_models/lamellarFF_HG.cpp", |
---|
| 170 | srcdir+"/lamellarFF_HG.c", |
---|
[27a0771] | 171 | #srcdir+"/CLamellarPSModel.c", |
---|
| 172 | "sans/models/c_models/CLamellarPSModel.cpp", |
---|
| 173 | "sans/models/c_models/lamellarPS.cpp", |
---|
| 174 | srcdir+"/lamellarPS.c", |
---|
| 175 | #srcdir+"/CLamellarPSHGModel.c", |
---|
| 176 | "sans/models/c_models/CLamellarPSHGModel.cpp", |
---|
| 177 | "sans/models/c_models/lamellarPS_HG.cpp", |
---|
| 178 | srcdir+"/lamellarPS_HG.c", |
---|
| 179 | #srcdir+"/COblateModel.c", |
---|
| 180 | "sans/models/c_models/COblateModel.cpp", |
---|
| 181 | "sans/models/c_models/oblate.cpp", |
---|
| 182 | srcdir+"/oblate.c", |
---|
| 183 | #srcdir+"/CProlateModel.c", |
---|
| 184 | "sans/models/c_models/CProlateModel.cpp", |
---|
| 185 | "sans/models/c_models/prolate.cpp", |
---|
| 186 | srcdir+"/prolate.c", |
---|
[3d25331f] | 187 | #srcdir+"/CMultishellModel.c", |
---|
| 188 | "sans/models/c_models/CMultishellModel.cpp", |
---|
| 189 | "sans/models/c_models/multishell.cpp", |
---|
| 190 | srcdir+"/multishell.c", |
---|
| 191 | #srcdir+"/CVesicleModel.c", |
---|
| 192 | "sans/models/c_models/CVesicleModel.cpp", |
---|
| 193 | "sans/models/c_models/vesicle.cpp", |
---|
| 194 | srcdir+"/vesicle.c", |
---|
| 195 | #srcdir+"/CBinaryHSModel.c", |
---|
| 196 | "sans/models/c_models/CBinaryHSModel.cpp", |
---|
| 197 | "sans/models/c_models/binaryHS.cpp", |
---|
| 198 | srcdir+"/binaryHS.c", |
---|
[ae3ce4e] | 199 | srcdir+"/disperser.c", |
---|
| 200 | igordir+"/libCylinder.c", |
---|
[25579e8] | 201 | igordir+"/libStructureFactor.c", |
---|
[ae3ce4e] | 202 | igordir+"/libSphere.c", |
---|
| 203 | srcdir+"/gaussian.c", |
---|
| 204 | srcdir+"/CGaussian.c", |
---|
| 205 | srcdir+"/lorentzian.c", |
---|
| 206 | srcdir+"/CLorentzian.c" |
---|
| 207 | ], |
---|
[812b901] | 208 | include_dirs=[igordir,srcdir,"sans/models/c_models",numpy_incl_path])]) |
---|
[ae3ce4e] | 209 | |
---|