source: sasview/sasmodels/setup.py @ 79492222

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 79492222 was 79492222, checked in by krzywon, 9 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1"""
2 Installation script for SANS models
3"""
4
5import sys
6import os
7import platform
8from numpy.distutils.misc_util import get_numpy_include_dirs
9numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy")
10   
11# Then build and install the modules
12from distutils.core import Extension, setup
13from distutils.command.build_ext import build_ext
14
15# Manage version number ######################################
16sys.path.append(os.path.join("src", "sans"))
17import models
18VERSION = models.__version__
19print "Building models v%s" % VERSION
20##############################################################
21
22# Options to enable OpenMP
23copt =  {'msvc': ['/openmp'],
24         'mingw32' : ['-fopenmp'],
25         'unix' : ['-fopenmp']}
26lopt =  {'msvc': ['/MANIFEST'],
27         'mingw32' : ['-fopenmp'],
28         'unix' : ['-lgomp']}
29
30# Options for non-openmp builds. MSVC always needs MANIFEST
31if sys.argv[-1] == "-nomp":
32    copt = {}
33    lopt = {'msvc': ['/MANIFEST']}
34
35class build_ext_subclass( build_ext ):
36    def build_extensions(self):
37        # Get 64-bitness
38        if sys.version_info >= (2, 6):
39            is_64bits = sys.maxsize > 2**32
40        else:
41            # 'sys.maxsize' and 64bit: Not supported for python2.5
42            is_64bits = False
43        c = self.compiler.compiler_type
44        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
45       
46        if not (sys.platform=='darwin' and not is_64bits):
47            if copt.has_key(c):
48               for e in self.extensions:
49                   e.extra_compile_args = copt[ c ]
50            if lopt.has_key(c):
51                for e in self.extensions:
52                    e.extra_link_args = lopt[ c ]
53                   
54        build_ext.build_extensions(self)
55
56# Build the module name
57includedir  = "include"
58igordir = os.path.join("src", "libigor")
59c_model_dir = os.path.join("src", "c_models")
60smear_dir  = os.path.join("src", "c_smearer")
61wrapper_dir  = os.path.join("src", "python_wrapper", "generated")
62if not os.path.isdir(wrapper_dir):
63    os.makedirs(wrapper_dir)
64
65sys.path.append(os.path.join("src", "python_wrapper"))
66from wrapping import generate_wrappers
67generate_wrappers(header_dir=includedir, 
68                  output_dir=os.path.join("src", "sans", "models"), 
69                  c_wrapper_dir=wrapper_dir)
70
71IGNORED_FILES = [".svn"]
72if not os.name=='nt':
73    IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])
74
75EXTENSIONS = [".c", ".cpp"]
76
77def append_file(file_list, dir_path):
78    """
79    Add sources file to sources
80    """
81    for f in os.listdir(dir_path):
82        if os.path.isfile(os.path.join(dir_path, f)):
83            _, ext = os.path.splitext(f)
84            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
85                file_list.append(os.path.join(dir_path, f)) 
86        elif os.path.isdir(os.path.join(dir_path, f)) and \
87                not f.startswith("."):
88            sub_dir = os.path.join(dir_path, f)
89            for new_f in os.listdir(sub_dir):
90                if os.path.isfile(os.path.join(sub_dir, new_f)):
91                    _, ext = os.path.splitext(new_f)
92                    if ext.lower() in EXTENSIONS and\
93                         new_f not in IGNORED_FILES:
94                        file_list.append(os.path.join(sub_dir, new_f)) 
95       
96model_sources = []
97append_file(file_list=model_sources, dir_path=igordir)
98append_file(file_list=model_sources, dir_path=c_model_dir)
99append_file(file_list=model_sources, dir_path=wrapper_dir)
100smear_sources = []
101append_file(file_list=smear_sources, dir_path=smear_dir)
102
103
104smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
105                  os.path.join(smear_dir, "smearer_module.cpp")]
106if os.name=='nt':
107    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
108
109dist = setup(
110    name="sansmodels",
111    version = VERSION,
112    description = "Python module for SANS scattering models",
113    author = "SANS/DANSE",
114    author_email = "sansdanse@gmail.gov",
115    url = "http://sansviewproject.svn.sourceforge.net",
116   
117    # Place this module under the sans package
118    #ext_package = "sans",
119   
120    # Use the pure python modules
121    package_dir = {"sans":os.path.join("src", "sans"),
122                   "sans.models":os.path.join("src", "sans", "models"),
123                   "sans.models.sans_extension":os.path.join("src", "sans", "models", "sans_extension"),
124                  },
125    package_data={'sans.models': [os.path.join('media', "*")]},
126    packages = ["sans","sans.models",
127                "sans.models.sans_extension",],
128   
129    ext_modules = [ 
130                   
131        Extension("sans.models.sans_extension.c_models",
132                    sources=model_sources,                 
133                    include_dirs=[igordir, includedir, c_model_dir, numpy_incl_path],   
134                    ),
135
136        # Smearer extension
137        Extension("sans.models.sans_extension.smearer",
138                   sources = smearer_sources,
139                   include_dirs=[igordir, smear_dir, numpy_incl_path],
140                   ),
141                   
142        Extension("sans.models.sans_extension.smearer2d_helper",
143                  sources = [os.path.join(smear_dir, 
144                                          "smearer2d_helper_module.cpp"),
145                             os.path.join(smear_dir, "smearer2d_helper.cpp"),],
146                  include_dirs=[smear_dir,numpy_incl_path],
147                  )
148        ],
149    cmdclass = {'build_ext': build_ext_subclass }
150    )
151       
Note: See TracBrowser for help on using the repository browser.