source: sasview/sansmodels/setup.py @ 0e307de

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 0e307de was d9673d7a, checked in by Jae Cho <jhjcho@…>, 12 years ago

fix for python25: sys.maxsize not exist

  • Property mode set to 100644
File size: 5.1 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# Options to enable OpenMP
16copt =  {'msvc': ['/openmp'],
17         'mingw32' : ['-fopenmp'],
18         'unix' : ['-fopenmp']}
19lopt =  {'msvc': ['/MANIFEST'],
20         'mingw32' : ['-fopenmp'],
21         'unix' : ['-lgomp']}
22
23class build_ext_subclass( build_ext ):
24    def build_extensions(self):
25        # Get 64-bitness
26        if sys.version_info >= (2, 6):
27            is_64bits = sys.maxsize > 2**32
28        else:
29            # 'sys.maxsize' and 64bit: Not supported for python2.5
30            is_64bits = False
31        c = self.compiler.compiler_type
32        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
33       
34        if not (sys.platform=='darwin' and not is_64bits):
35            if copt.has_key(c):
36               for e in self.extensions:
37                   e.extra_compile_args = copt[ c ]
38            if lopt.has_key(c):
39                for e in self.extensions:
40                    e.extra_link_args = lopt[ c ]
41                   
42        build_ext.build_extensions(self)
43
44# Build the module name
45srcdir  = os.path.join("src", "sans", "models", "c_extensions")
46igordir = os.path.join("src","sans", "models", "libigor")
47c_model_dir = os.path.join("src", "sans", "models", "c_models")
48smear_dir  = os.path.join("src", "sans", "models", "c_smearer")
49print "Installing SANS models"
50
51
52IGNORED_FILES = ["a.exe",
53                 "__init__.py"
54                 ".svn",
55                   "lineparser.py",
56                   "run.py",
57                   "CGaussian.cpp",
58                   "CLogNormal.cpp",
59                   "CLorentzian.cpp",
60                   "CSchulz.cpp",
61                   "WrapperGenerator.py",
62                   "wrapping.py"
63                   ]
64if not os.name=='nt':
65    IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])
66
67EXTENSIONS = [".c", ".cpp"]
68
69def append_file(file_list, dir_path):
70    """
71    Add sources file to sources
72    """
73    for f in os.listdir(dir_path):
74        if os.path.isfile(os.path.join(dir_path, f)):
75            _, ext = os.path.splitext(f)
76            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
77                file_list.append(os.path.join(dir_path, f)) 
78        elif os.path.isdir(os.path.join(dir_path, f)) and \
79                not f.startswith("."):
80            sub_dir = os.path.join(dir_path, f)
81            for new_f in os.listdir(sub_dir):
82                if os.path.isfile(os.path.join(sub_dir, new_f)):
83                    _, ext = os.path.splitext(new_f)
84                    if ext.lower() in EXTENSIONS and\
85                         new_f not in IGNORED_FILES:
86                        file_list.append(os.path.join(sub_dir, new_f)) 
87       
88model_sources = []
89append_file(file_list=model_sources, dir_path=srcdir)
90append_file(file_list=model_sources, dir_path=igordir)
91append_file(file_list=model_sources, dir_path=c_model_dir)
92smear_sources = []
93append_file(file_list=smear_sources, dir_path=smear_dir)
94
95
96smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
97                  os.path.join(smear_dir, "smearer_module.cpp")]
98if os.name=='nt':
99    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
100
101dist = setup(
102    name="sansmodels",
103    version = "1.0.0",
104    description = "Python module for SANS scattering models",
105    author = "SANS/DANSE",
106    author_email = "sansdanse@gmail.gov",
107    url = "http://danse.us/trac/sans",
108   
109    # Place this module under the sans package
110    #ext_package = "sans",
111   
112    # Use the pure python modules
113    package_dir = {"sans":os.path.join("src", "sans"),
114                   "sans.models":os.path.join("src", "sans", "models"),
115                   "sans.models.sans_extension":srcdir,
116                  },
117    package_data={'sans.models': [os.path.join('media', "*")]},
118    packages = ["sans","sans.models",
119                "sans.models.sans_extension",],
120   
121    ext_modules = [ Extension("sans.models.sans_extension.c_models",
122                              sources=model_sources,                 
123                              include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path],   
124                              ),
125   
126        # Smearer extension
127        Extension("sans.models.sans_extension.smearer",
128                   sources = smearer_sources,
129                   include_dirs=[igordir, smear_dir, numpy_incl_path],
130                   ),
131                   
132        Extension("sans.models.sans_extension.smearer2d_helper",
133                  sources = [os.path.join(smear_dir, 
134                                          "smearer2d_helper_module.cpp"),
135                             os.path.join(smear_dir, "smearer2d_helper.cpp"),],
136                  include_dirs=[smear_dir,numpy_incl_path],
137                  )
138        ],
139    cmdclass = {'build_ext': build_ext_subclass }
140    )
141       
Note: See TracBrowser for help on using the repository browser.