source: sasview/sansmodels/setup.py @ 857d00f

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 857d00f was 5953b77, checked in by Jae Cho <jhjcho@…>, 13 years ago

changed the name of package

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