source: sasview/sansmodels/src/setup.py @ eb575b0

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since eb575b0 was b72b595, checked in by Chris Farrow <cfarrow@…>, 15 years ago

Made installer more robust on linux. Must test on other platforms.

  • Property mode set to 100644
File size: 8.6 KB
Line 
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"""
12import sys
13import os
14
15toks = sys.version.split('.')
16if sys.platform.count("win32")>0 or sys.platform.count("win64"):
17    py_path = "lib"
18else:
19    py_path = os.path.join("lib","python"+toks[0]+"."+toks[1])
20numpy_incl_path = os.path.join(sys.prefix, py_path, "site-packages", "numpy", "core", "include", "numpy")
21
22from numpy.distutils.misc_util import get_numpy_include_dirs
23numpy_incl_path = os.path.extend(get_numpy_include_dirs()[0], "numpy")
24
25def createODBcontent(class_name):
26    """
27        Return the content of the Pyre odb file for a given class
28        @param class_name: Name of the class to write an odb file for [string]
29        @return: content of the file [string]
30    """
31    content  = "\"\"\"\n"
32    content += "  Facility for SANS model\n\n"
33    content += "  WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n"
34    content += "           DO NOT MODIFY\n\n"
35    content += "  This code was written as part of the DANSE project\n"
36    content += "  http://danse.us/trac/sans/\n"
37    content += "  @copyright 2007:"
38    content += "  SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n"
39    content += "\"\"\"\n"
40    content += "def model():\n"
41    content += "    from ScatteringIntensityFactory import ScatteringIntensityFactory\n"
42    content += "    from sans.models.%s import %s\n" % (class_name, class_name)
43    content += "    return ScatteringIntensityFactory(%s)('%s')\n"\
44                 % (class_name, class_name)
45
46    return content
47
48def createODBfiles():
49    """
50       Create odb files for all available models
51    """
52    from sans.models.ModelFactory import ModelFactory
53   
54    class_list = ModelFactory().getAllModels()
55    for name in class_list:
56        odb = open("sans/models/pyre/%s.odb" % name, 'w')
57        odb.write(createODBcontent(name))
58        odb.close()
59        print "sans/models/pyre/%s.odb created" % name
60       
61#
62# Proceed with installation
63#
64
65# First, create the odb files
66if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb':
67    print "Creating odb files"
68    try:
69        createODBfiles()
70    except:   
71        print "ERROR: could not create odb files"
72        print sys.exc_value
73    sys.exit()
74
75# Then build and install the modules
76from distutils.core import setup, Extension
77
78
79# Build the module name
80srcdir  = "sans/models/c_extensions"
81igordir = "libigor"
82
83print "Installing SANS models"
84
85
86setup(
87    name="models",
88    version = "0.1",
89    description = "Python module for SANS scattering models",
90    author = "Mathieu Doucet",
91    author_email = "doucet@nist.gov",
92    url = "http://danse.us/trac/sans",
93   
94    # Place this module under the sans package
95    #ext_package = "sans",
96   
97    # Use the pure python modules
98    package_dir = {"sans_extension":"sans/models/c_extensions"},
99   
100    packages = ["sans","sans.models","sans.models.test",
101                "sans_extension","sans.models.pyre"],
102   
103    ext_modules = [ Extension("sans_extension.c_models",
104     sources = [
105        "sans/models/c_models/c_models.cpp",
106        #srcdir+"/CSphereModel.c",
107        #srcdir+"/sphere.c",
108        "sans/models/c_models/CSphereModel.cpp",
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", 
117        "sans/models/c_models/Hardsphere.cpp",   
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", 
123        "sans/models/c_models/DiamEllip.cpp",     
124        srcdir+"/HayterMSA.c",         
125        "sans/models/c_models/CHayterMSAStructure.cpp", 
126        "sans/models/c_models/HayterMSA.cpp",             
127        "sans/models/c_models/sphere.cpp",
128        #srcdir+"/CCylinderModel.c",
129        "sans/models/c_models/CCylinderModel.cpp",
130        "sans/models/c_models/cylinder.cpp",
131        "sans/models/c_models/parameters.cpp",
132        "sans/models/c_models/dispersion_visitor.cpp",
133        srcdir+"/cylinder.c",
134        #srcdir+"/CParallelepiped.c",
135        "sans/models/c_models/CParallelepipedModel.cpp",
136        "sans/models/c_models/parallelepiped.cpp",
137        srcdir+"/parallelepiped.c",
138        #srcdir+"/CCoreShellCylinderModel.c",
139        "sans/models/c_models/CCoreShellCylinderModel.cpp",
140        "sans/models/c_models/coreshellcylinder.cpp",
141        srcdir+"/core_shell_cylinder.c",
142        #srcdir+"/CHollowCylinderModel.c",
143        "sans/models/c_models/CHollowCylinderModel.cpp",
144        "sans/models/c_models/hollowcylinder.cpp",
145        srcdir+"/hollow_cylinder.c",
146        #srcdir+"/CCoreShellModel.c",
147        #srcdir+"/core_shell.c",
148        "sans/models/c_models/CCoreShellModel.cpp",
149        "sans/models/c_models/coreshellsphere.cpp",
150        #srcdir+"/CEllipsoidModel.c",
151        "sans/models/c_models/CEllipsoidModel.cpp",
152        "sans/models/c_models/ellipsoid.cpp",       
153        srcdir+"/ellipsoid.c",
154        #srcdir+"/CEllipticalCylinderModel.c",
155        "sans/models/c_models/CEllipticalCylinderModel.cpp",
156        "sans/models/c_models/ellipticalcylinder.cpp",               
157        srcdir+"/elliptical_cylinder.c",
158        #srcdir+"/CTriaxialEllipsoidModel.c",
159        "sans/models/c_models/CTriaxialEllipsoidModel.cpp",
160        "sans/models/c_models/triaxialellipsoid.cpp",               
161        srcdir+"/triaxial_ellipsoid.c",
162        #srcdir+"/CFlexibleCylinderModel.c",
163        "sans/models/c_models/CFlexibleCylinderModel.cpp",
164        "sans/models/c_models/flexiblecylinder.cpp",               
165        srcdir+"/flexible_cylinder.c",
166        #srcdir+"/CStakedDisksModel.c",
167        "sans/models/c_models/CStackedDisksModel.cpp",
168        "sans/models/c_models/stackeddisks.cpp",               
169        srcdir+"/stacked_disks.c",
170        #srcdir+"/CLamellarModel.c",
171        "sans/models/c_models/CLamellarModel.cpp",
172        "sans/models/c_models/lamellar.cpp",               
173        srcdir+"/lamellar.c",
174        #srcdir+"/CLamellarFFHGModel.c",
175        "sans/models/c_models/CLamellarFFHGModel.cpp",
176        "sans/models/c_models/lamellarFF_HG.cpp",               
177        srcdir+"/lamellarFF_HG.c",
178        #srcdir+"/CLamellarPSModel.c",
179        "sans/models/c_models/CLamellarPSModel.cpp",
180        "sans/models/c_models/lamellarPS.cpp",               
181        srcdir+"/lamellarPS.c",
182        #srcdir+"/CLamellarPSHGModel.c",
183        "sans/models/c_models/CLamellarPSHGModel.cpp",
184        "sans/models/c_models/lamellarPS_HG.cpp",               
185        srcdir+"/lamellarPS_HG.c",
186        #srcdir+"/COblateModel.c",
187        "sans/models/c_models/CCoreShellEllipsoidModel.cpp",
188        "sans/models/c_models/spheroid.cpp",   
189        srcdir+"/spheroid.c",             
190        #srcdir+"/COblateModel.c",
191        #"sans/models/c_models/COblateModel.cpp",
192        #"sans/models/c_models/oblate.cpp",               
193        #srcdir+"/oblate.c",
194        #srcdir+"/CProlateModel.c",
195        #"sans/models/c_models/CProlateModel.cpp",
196        #"sans/models/c_models/prolate.cpp",               
197        #srcdir+"/prolate.c",
198        #srcdir+"/CMultishellModel.c",
199        "sans/models/c_models/CMultiShellModel.cpp",
200        "sans/models/c_models/multishell.cpp",               
201        srcdir+"/multishell.c",
202        #srcdir+"/CVesicleModel.c",
203        "sans/models/c_models/CVesicleModel.cpp",
204        "sans/models/c_models/vesicle.cpp",               
205        srcdir+"/vesicle.c",
206        #srcdir+"/CBinaryHSModel.c",
207        "sans/models/c_models/CBinaryHSModel.cpp",
208        "sans/models/c_models/binaryHS.cpp",               
209        srcdir+"/binaryHS.c",
210        srcdir+"/disperser.c",
211        igordir+"/libCylinder.c",
212        igordir+"/libStructureFactor.c",
213        igordir+"/libSphere.c",
214        srcdir+"/gaussian.c",
215        srcdir+"/CGaussian.c",
216        srcdir+"/logNormal.c",
217        srcdir+"/CLogNormal.c",
218        srcdir+"/schulz.c",
219        srcdir+"/CSchulz.c",
220        srcdir+"/lorentzian.c",
221        srcdir+"/CLorentzian.c"
222            ],
223         include_dirs=[igordir,srcdir,"sans/models/c_models",numpy_incl_path])])
224       
Note: See TracBrowser for help on using the repository browser.