[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 | """ |
---|
| 12 | import sys |
---|
| 13 | |
---|
[6d61373] | 14 | if len(sys.argv) == 1: |
---|
| 15 | sys.argv.append('install') |
---|
| 16 | |
---|
[ae3ce4e] | 17 | def createODBcontent(class_name): |
---|
| 18 | """ |
---|
| 19 | Return the content of the Pyre odb file for a given class |
---|
| 20 | @param class_name: Name of the class to write an odb file for [string] |
---|
| 21 | @return: content of the file [string] |
---|
| 22 | """ |
---|
| 23 | content = "\"\"\"\n" |
---|
| 24 | content += " Facility for SANS model\n\n" |
---|
| 25 | content += " WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n" |
---|
| 26 | content += " DO NOT MODIFY\n\n" |
---|
| 27 | content += " This code was written as part of the DANSE project\n" |
---|
| 28 | content += " http://danse.us/trac/sans/\n" |
---|
| 29 | content += " @copyright 2007:" |
---|
[25579e8] | 30 | content += " SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n" |
---|
[ae3ce4e] | 31 | content += "\"\"\"\n" |
---|
| 32 | content += "def model():\n" |
---|
| 33 | content += " from ScatteringIntensityFactory import ScatteringIntensityFactory\n" |
---|
| 34 | content += " from sans.models.%s import %s\n" % (class_name, class_name) |
---|
| 35 | content += " return ScatteringIntensityFactory(%s)('%s')\n"\ |
---|
| 36 | % (class_name, class_name) |
---|
| 37 | |
---|
| 38 | return content |
---|
| 39 | |
---|
| 40 | def createODBfiles(): |
---|
| 41 | """ |
---|
| 42 | Create odb files for all available models |
---|
| 43 | """ |
---|
| 44 | from sans.models.ModelFactory import ModelFactory |
---|
| 45 | |
---|
| 46 | class_list = ModelFactory().getAllModels() |
---|
| 47 | for name in class_list: |
---|
| 48 | odb = open("sans/models/pyre/%s.odb" % name, 'w') |
---|
| 49 | odb.write(createODBcontent(name)) |
---|
| 50 | odb.close() |
---|
| 51 | print "sans/models/pyre/%s.odb created" % name |
---|
| 52 | |
---|
| 53 | # |
---|
| 54 | # Proceed with installation |
---|
| 55 | # |
---|
| 56 | |
---|
| 57 | # First, create the odb files |
---|
| 58 | if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb': |
---|
| 59 | print "Creating odb files" |
---|
| 60 | try: |
---|
| 61 | createODBfiles() |
---|
| 62 | except: |
---|
| 63 | print "ERROR: could not create odb files" |
---|
| 64 | print sys.exc_value |
---|
| 65 | sys.exit() |
---|
| 66 | |
---|
| 67 | # Then build and install the modules |
---|
| 68 | from distutils.core import setup, Extension |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | # Build the module name |
---|
| 72 | srcdir = "sans/models/c_extensions" |
---|
| 73 | igordir = "libigor" |
---|
| 74 | |
---|
| 75 | print "Installing SANS models" |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | setup( |
---|
| 79 | name="models", |
---|
| 80 | version = "0.1", |
---|
| 81 | description = "Python module for SANS scattering models", |
---|
| 82 | author = "Mathieu Doucet", |
---|
| 83 | author_email = "doucet@nist.gov", |
---|
| 84 | url = "http://danse.us/trac/sans", |
---|
| 85 | |
---|
| 86 | # Place this module under the sans package |
---|
| 87 | #ext_package = "sans", |
---|
| 88 | |
---|
| 89 | # Use the pure python modules |
---|
| 90 | package_dir = {"sans_extension":"sans/models/c_extensions"}, |
---|
| 91 | |
---|
| 92 | packages = ["sans","sans.models","sans.models.test", |
---|
| 93 | "sans_extension","sans.models.pyre"], |
---|
| 94 | |
---|
| 95 | ext_modules = [ Extension("sans_extension.c_models", |
---|
| 96 | sources = [ |
---|
[8809e48] | 97 | "sans/models/c_models/c_models.cpp", |
---|
[0f5bc9f] | 98 | #srcdir+"/CSphereModel.c", |
---|
| 99 | #srcdir+"/sphere.c", |
---|
| 100 | "sans/models/c_models/CSphereModel.cpp", |
---|
[25579e8] | 101 | srcdir+"/SquareWell.c", |
---|
| 102 | "sans/models/c_models/CSquareWellStructure.cpp", |
---|
| 103 | "sans/models/c_models/SquareWell.cpp", |
---|
| 104 | srcdir+"/StickyHS.c", |
---|
| 105 | "sans/models/c_models/CStickyHSStructure.cpp", |
---|
| 106 | "sans/models/c_models/StickyHS.cpp", |
---|
| 107 | srcdir+"/Hardsphere.c", |
---|
| 108 | "sans/models/c_models/CHardsphereStructure.cpp", |
---|
| 109 | "sans/models/c_models/Hardsphere.cpp", |
---|
| 110 | srcdir+"/HayterMSA.c", |
---|
| 111 | "sans/models/c_models/CHayterMSAStructure.cpp", |
---|
| 112 | "sans/models/c_models/HayterMSA.cpp", |
---|
[0f5bc9f] | 113 | "sans/models/c_models/sphere.cpp", |
---|
[af03ddd] | 114 | #srcdir+"/CCylinderModel.c", |
---|
| 115 | "sans/models/c_models/CCylinderModel.cpp", |
---|
| 116 | "sans/models/c_models/cylinder.cpp", |
---|
| 117 | "sans/models/c_models/parameters.cpp", |
---|
| 118 | "sans/models/c_models/dispersion_visitor.cpp", |
---|
[ae3ce4e] | 119 | srcdir+"/cylinder.c", |
---|
[0f5bc9f] | 120 | #srcdir+"/CCoreShellCylinderModel.c", |
---|
| 121 | "sans/models/c_models/CCoreShellCylinderModel.cpp", |
---|
| 122 | "sans/models/c_models/coreshellcylinder.cpp", |
---|
[ae3ce4e] | 123 | srcdir+"/core_shell_cylinder.c", |
---|
[0f5bc9f] | 124 | #srcdir+"/CCoreShellModel.c", |
---|
| 125 | #srcdir+"/core_shell.c", |
---|
| 126 | "sans/models/c_models/CCoreShellModel.cpp", |
---|
| 127 | "sans/models/c_models/coreshellsphere.cpp", |
---|
| 128 | #srcdir+"/CEllipsoidModel.c", |
---|
| 129 | "sans/models/c_models/CEllipsoidModel.cpp", |
---|
| 130 | "sans/models/c_models/ellipsoid.cpp", |
---|
[ae3ce4e] | 131 | srcdir+"/ellipsoid.c", |
---|
[0f5bc9f] | 132 | #srcdir+"/CEllipticalCylinderModel.c", |
---|
| 133 | "sans/models/c_models/CEllipticalCylinderModel.cpp", |
---|
| 134 | "sans/models/c_models/ellipticalcylinder.cpp", |
---|
[ae3ce4e] | 135 | srcdir+"/elliptical_cylinder.c", |
---|
| 136 | srcdir+"/disperser.c", |
---|
| 137 | igordir+"/libCylinder.c", |
---|
[25579e8] | 138 | igordir+"/libStructureFactor.c", |
---|
[ae3ce4e] | 139 | igordir+"/libSphere.c", |
---|
| 140 | srcdir+"/gaussian.c", |
---|
| 141 | srcdir+"/CGaussian.c", |
---|
| 142 | srcdir+"/lorentzian.c", |
---|
| 143 | srcdir+"/CLorentzian.c" |
---|
| 144 | ], |
---|
[af03ddd] | 145 | include_dirs=[igordir,srcdir,"sans/models/c_models"])]) |
---|
[ae3ce4e] | 146 | |
---|