source: sasview/sansmodels/setup.py @ 2371363

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 2371363 was 13f00a0, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #7 fix sansmodels setup.py

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[ae3ce4e]1"""
2 Installation script for SANS models
3"""
[d7a2531]4
[f88624d]5import sys
6import os
[0b082f3]7import platform
[b72b595]8from numpy.distutils.misc_util import get_numpy_include_dirs
[6c13861]9numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy")
[0abf7bf]10   
[ae3ce4e]11# Then build and install the modules
[87615a48]12from distutils.core import Extension, setup
[13f00a0]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        is_64bits = sys.maxsize > 2**32
27       
28        c = self.compiler.compiler_type
29        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
30       
31        if not (sys.platform=='darwin' and not is_64bits):
32            if copt.has_key(c):
33               for e in self.extensions:
34                   e.extra_compile_args = copt[ c ]
35            if lopt.has_key(c):
36                for e in self.extensions:
37                    e.extra_link_args = lopt[ c ]
38                   
39        build_ext.build_extensions(self)
[ae3ce4e]40
41# Build the module name
[0a51f0d8]42srcdir  = os.path.join("src", "sans", "models", "c_extensions")
43igordir = os.path.join("src","sans", "models", "libigor")
44c_model_dir = os.path.join("src", "sans", "models", "c_models")
45smear_dir  = os.path.join("src", "sans", "models", "c_smearer")
[ae3ce4e]46print "Installing SANS models"
47
48
[0a51f0d8]49IGNORED_FILES = ["a.exe",
50                 "__init__.py"
51                 ".svn",
52                   "lineparser.py",
53                   "run.py",
54                   "CGaussian.cpp",
55                   "CLogNormal.cpp",
56                   "CLorentzian.cpp",
57                   "CSchulz.cpp",
58                   "WrapperGenerator.py",
[f9303b6]59                   "wrapping.py"
60                   ]
61if not os.name=='nt':
62    IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])
63
[0f282a5]64EXTENSIONS = [".c", ".cpp"]
[0a51f0d8]65
66def append_file(file_list, dir_path):
67    """
68    Add sources file to sources
69    """
70    for f in os.listdir(dir_path):
71        if os.path.isfile(os.path.join(dir_path, f)):
72            _, ext = os.path.splitext(f)
[0f282a5]73            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
[0a51f0d8]74                file_list.append(os.path.join(dir_path, f)) 
75        elif os.path.isdir(os.path.join(dir_path, f)) and \
76                not f.startswith("."):
77            sub_dir = os.path.join(dir_path, f)
78            for new_f in os.listdir(sub_dir):
79                if os.path.isfile(os.path.join(sub_dir, new_f)):
80                    _, ext = os.path.splitext(new_f)
[0f282a5]81                    if ext.lower() in EXTENSIONS and\
[0a51f0d8]82                         new_f not in IGNORED_FILES:
83                        file_list.append(os.path.join(sub_dir, new_f)) 
84       
85model_sources = []
86append_file(file_list=model_sources, dir_path=srcdir)
87append_file(file_list=model_sources, dir_path=igordir)
88append_file(file_list=model_sources, dir_path=c_model_dir)
89smear_sources = []
90append_file(file_list=smear_sources, dir_path=smear_dir)
91
92
[f9303b6]93smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
94                  os.path.join(smear_dir, "smearer_module.cpp")]
95if os.name=='nt':
96    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
97
[87615a48]98dist = setup(
[5953b77]99    name="sansmodels",
[a2898df]100    version = "1.0.0",
[ae3ce4e]101    description = "Python module for SANS scattering models",
[87615a48]102    author = "SANS/DANSE",
103    author_email = "sansdanse@gmail.gov",
[ae3ce4e]104    url = "http://danse.us/trac/sans",
105   
106    # Place this module under the sans package
107    #ext_package = "sans",
108   
109    # Use the pure python modules
[0a51f0d8]110    package_dir = {"sans":os.path.join("src", "sans"),
111                   "sans.models":os.path.join("src", "sans", "models"),
112                   "sans.models.sans_extension":srcdir,
[42c974f]113                  },
114    package_data={'sans.models': [os.path.join('media', "*")]},
115    packages = ["sans","sans.models",
[0abf7bf]116                "sans.models.sans_extension",],
[ae3ce4e]117   
[c089120]118    ext_modules = [ Extension("sans.models.sans_extension.c_models",
[0b082f3]119                              sources=model_sources,                 
120                              include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path],   
121                              ),
122   
[87615a48]123        # Smearer extension
[c089120]124        Extension("sans.models.sans_extension.smearer",
[f9303b6]125                   sources = smearer_sources,
[13f00a0]126                   include_dirs=[igordir, smear_dir, numpy_incl_path],
127                   ),
128                   
[c089120]129        Extension("sans.models.sans_extension.smearer2d_helper",
[0a51f0d8]130                  sources = [os.path.join(smear_dir, 
131                                          "smearer2d_helper_module.cpp"),
132                             os.path.join(smear_dir, "smearer2d_helper.cpp"),],
[0b082f3]133                  include_dirs=[smear_dir,numpy_incl_path],
[13f00a0]134                  )
135        ],
136    cmdclass = {'build_ext': build_ext_subclass }
[87615a48]137    )
[b72b595]138       
Note: See TracBrowser for help on using the repository browser.