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