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

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 f52bea1 was ae3ce4e, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

Moving sansmodels to trunk

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[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"""
12import sys
13
14def 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
37def 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
55if 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
65from distutils.core import setup, Extension
66
67
68# Build the module name
69srcdir  = "sans/models/c_extensions"
70igordir = "libigor"
71
72print "Installing SANS models"
73
74
75setup(
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.c",
95        srcdir+"/CSphereModel.c",
96        srcdir+"/sphere.c",
97        srcdir+"/CCylinderModel.c",
98        srcdir+"/cylinder.c",
99        srcdir+"/CCoreShellCylinderModel.c",
100        srcdir+"/core_shell_cylinder.c",
101        srcdir+"/CCoreShellModel.c",
102        srcdir+"/core_shell.c",
103        srcdir+"/CEllipsoidModel.c",
104        srcdir+"/ellipsoid.c",
105        srcdir+"/CEllipticalCylinderModel.c",
106        srcdir+"/elliptical_cylinder.c",
107        srcdir+"/disperser.c",
108        igordir+"/libCylinder.c",
109        igordir+"/libSphere.c",
110        srcdir+"/gaussian.c",
111        srcdir+"/CGaussian.c",
112        srcdir+"/lorentzian.c",
113        srcdir+"/CLorentzian.c"
114            ],
115         include_dirs=[igordir])])
116       
Note: See TracBrowser for help on using the repository browser.