source: sasview/sansmodels/setup.py @ ea6e8b6

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 ea6e8b6 was d7a2531, checked in by Gervaise Alina <gervyh@…>, 13 years ago

remove unused command

  • Property mode set to 100644
File size: 5.7 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"""
12
13import sys
14import os
15
16   
17from numpy.distutils.misc_util import get_numpy_include_dirs
18numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy")
19
20def createODBcontent(class_name):
21    """
22        Return the content of the Pyre odb file for a given class
23        @param class_name: Name of the class to write an odb file for [string]
24        @return: content of the file [string]
25    """
26    content  = "\"\"\"\n"
27    content += "  Facility for SANS model\n\n"
28    content += "  WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n"
29    content += "           DO NOT MODIFY\n\n"
30    content += "  This code was written as part of the DANSE project\n"
31    content += "  http://danse.us/trac/sans/\n"
32    content += "  @copyright 2007:"
33    content += "  SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n"
34    content += "\"\"\"\n"
35    content += "def model():\n"
36    content += "    from ScatteringIntensityFactory import ScatteringIntensityFactory\n"
37    content += "    from sans.models.%s import %s\n" % (class_name, class_name)
38    content += "    return ScatteringIntensityFactory(%s)('%s')\n"\
39                 % (class_name, class_name)
40
41    return content
42
43def createODBfiles():
44    """
45       Create odb files for all available models
46    """
47    from sans.models.ModelFactory import ModelFactory
48   
49    class_list = ModelFactory().getAllModels()
50    for name in class_list:
51        odb = open("src/sans/models/pyre/%s.odb" % name, 'w')
52        odb.write(createODBcontent(name))
53        odb.close()
54        print "src/sans/models/pyre/%s.odb created" % name
55       
56#
57# Proceed with installation
58#
59
60# First, create the odb files
61if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb':
62    print "Creating odb files"
63    try:
64        createODBfiles()
65    except:   
66        print "ERROR: could not create odb files"
67        print sys.exc_value
68    sys.exit()
69
70# Then build and install the modules
71from distutils.core import Extension, setup
72#from setuptools import setup#, find_packages
73
74# Build the module name
75srcdir  = os.path.join("src", "sans", "models", "c_extensions")
76igordir = os.path.join("src","sans", "models", "libigor")
77c_model_dir = os.path.join("src", "sans", "models", "c_models")
78smear_dir  = os.path.join("src", "sans", "models", "c_smearer")
79print "Installing SANS models"
80
81
82IGNORED_FILES = ["a.exe",
83                 "__init__.py"
84                 ".svn",
85                   "lineparser.py",
86                   "run.py",
87                   "CGaussian.cpp",
88                   "CLogNormal.cpp",
89                   "CLorentzian.cpp",
90                   "CSchulz.cpp",
91                   "WrapperGenerator.py",
92                   "wrapping.py",
93                   "winFuncs.c"]
94EXTENSIONS = [".c", ".cpp"]
95
96def append_file(file_list, dir_path):
97    """
98    Add sources file to sources
99    """
100    for f in os.listdir(dir_path):
101        if os.path.isfile(os.path.join(dir_path, f)):
102            _, ext = os.path.splitext(f)
103            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
104                file_list.append(os.path.join(dir_path, f)) 
105        elif os.path.isdir(os.path.join(dir_path, f)) and \
106                not f.startswith("."):
107            sub_dir = os.path.join(dir_path, f)
108            for new_f in os.listdir(sub_dir):
109                if os.path.isfile(os.path.join(sub_dir, new_f)):
110                    _, ext = os.path.splitext(new_f)
111                    if ext.lower() in EXTENSIONS and\
112                         new_f not in IGNORED_FILES:
113                        file_list.append(os.path.join(sub_dir, new_f)) 
114       
115model_sources = []
116append_file(file_list=model_sources, dir_path=srcdir)
117append_file(file_list=model_sources, dir_path=igordir)
118append_file(file_list=model_sources, dir_path=c_model_dir)
119smear_sources = []
120append_file(file_list=smear_sources, dir_path=smear_dir)
121
122
123dist = setup(
124    name="sansmodels",
125    version = "1.0.0",
126    description = "Python module for SANS scattering models",
127    author = "SANS/DANSE",
128    author_email = "sansdanse@gmail.gov",
129    url = "http://danse.us/trac/sans",
130   
131    # Place this module under the sans package
132    #ext_package = "sans",
133   
134    # Use the pure python modules
135    package_dir = {"sans":os.path.join("src", "sans"),
136                   "sans.models":os.path.join("src", "sans", "models"),
137                   "sans.models.sans_extension":srcdir,
138                  },
139    package_data={'sans.models': [os.path.join('media', "*")]},
140    packages = ["sans","sans.models",
141                "sans.models.sans_extension","sans.models.pyre",],
142   
143    ext_modules = [ Extension("sans.models.sans_extension.c_models",
144             sources=model_sources,                 
145     
146        include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]),       
147        # Smearer extension
148        Extension("sans.models.sans_extension.smearer",
149                   sources = [os.path.join(smear_dir, 
150                                          "smearer.cpp"),
151                             os.path.join(smear_dir, "smearer_module.cpp"),],
152        include_dirs=[smear_dir, numpy_incl_path]),
153        Extension("sans.models.sans_extension.smearer2d_helper",
154                  sources = [os.path.join(smear_dir, 
155                                          "smearer2d_helper_module.cpp"),
156                             os.path.join(smear_dir, "smearer2d_helper.cpp"),],
157        include_dirs=[smear_dir,numpy_incl_path]
158        )
159        ]
160    )
161       
Note: See TracBrowser for help on using the repository browser.