source: sasview/sansmodels/setup.py @ 8bac371

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

Re #5 fixing samsmodels compilation on MSVC

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[ae3ce4e]1"""
2 Installation script for SANS models
3"""
[d7a2531]4
[f88624d]5import sys
6import os
[b72b595]7from numpy.distutils.misc_util import get_numpy_include_dirs
[6c13861]8numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy")
[0abf7bf]9   
[ae3ce4e]10# Then build and install the modules
[87615a48]11from distutils.core import Extension, setup
12#from setuptools import setup#, find_packages
[ae3ce4e]13
14# Build the module name
[0a51f0d8]15srcdir  = os.path.join("src", "sans", "models", "c_extensions")
16igordir = os.path.join("src","sans", "models", "libigor")
17c_model_dir = os.path.join("src", "sans", "models", "c_models")
18smear_dir  = os.path.join("src", "sans", "models", "c_smearer")
[ae3ce4e]19print "Installing SANS models"
20
21
[0a51f0d8]22IGNORED_FILES = ["a.exe",
23                 "__init__.py"
24                 ".svn",
25                   "lineparser.py",
26                   "run.py",
27                   "CGaussian.cpp",
28                   "CLogNormal.cpp",
29                   "CLorentzian.cpp",
30                   "CSchulz.cpp",
31                   "WrapperGenerator.py",
[f9303b6]32                   "wrapping.py"
33                   ]
34if not os.name=='nt':
35    IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"])
36
[0f282a5]37EXTENSIONS = [".c", ".cpp"]
[0a51f0d8]38
39def append_file(file_list, dir_path):
40    """
41    Add sources file to sources
42    """
43    for f in os.listdir(dir_path):
44        if os.path.isfile(os.path.join(dir_path, f)):
45            _, ext = os.path.splitext(f)
[0f282a5]46            if ext.lower() in EXTENSIONS and f not in IGNORED_FILES:
[0a51f0d8]47                file_list.append(os.path.join(dir_path, f)) 
48        elif os.path.isdir(os.path.join(dir_path, f)) and \
49                not f.startswith("."):
50            sub_dir = os.path.join(dir_path, f)
51            for new_f in os.listdir(sub_dir):
52                if os.path.isfile(os.path.join(sub_dir, new_f)):
53                    _, ext = os.path.splitext(new_f)
[0f282a5]54                    if ext.lower() in EXTENSIONS and\
[0a51f0d8]55                         new_f not in IGNORED_FILES:
56                        file_list.append(os.path.join(sub_dir, new_f)) 
57       
58model_sources = []
59append_file(file_list=model_sources, dir_path=srcdir)
60append_file(file_list=model_sources, dir_path=igordir)
61append_file(file_list=model_sources, dir_path=c_model_dir)
62smear_sources = []
63append_file(file_list=smear_sources, dir_path=smear_dir)
64
65
[f9303b6]66smearer_sources = [os.path.join(smear_dir, "smearer.cpp"),
67                  os.path.join(smear_dir, "smearer_module.cpp")]
68if os.name=='nt':
69    smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
70
[87615a48]71dist = setup(
[5953b77]72    name="sansmodels",
[a2898df]73    version = "1.0.0",
[ae3ce4e]74    description = "Python module for SANS scattering models",
[87615a48]75    author = "SANS/DANSE",
76    author_email = "sansdanse@gmail.gov",
[ae3ce4e]77    url = "http://danse.us/trac/sans",
78   
79    # Place this module under the sans package
80    #ext_package = "sans",
81   
82    # Use the pure python modules
[0a51f0d8]83    package_dir = {"sans":os.path.join("src", "sans"),
84                   "sans.models":os.path.join("src", "sans", "models"),
85                   "sans.models.sans_extension":srcdir,
[42c974f]86                  },
87    package_data={'sans.models': [os.path.join('media', "*")]},
88    packages = ["sans","sans.models",
[0abf7bf]89                "sans.models.sans_extension",],
[ae3ce4e]90   
[c089120]91    ext_modules = [ Extension("sans.models.sans_extension.c_models",
[0a51f0d8]92             sources=model_sources,                 
93     
94        include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]),       
[87615a48]95        # Smearer extension
[c089120]96        Extension("sans.models.sans_extension.smearer",
[f9303b6]97                   sources = smearer_sources,
98                   include_dirs=[smear_dir, numpy_incl_path]),
[c089120]99        Extension("sans.models.sans_extension.smearer2d_helper",
[0a51f0d8]100                  sources = [os.path.join(smear_dir, 
101                                          "smearer2d_helper_module.cpp"),
102                             os.path.join(smear_dir, "smearer2d_helper.cpp"),],
[f9303b6]103                  include_dirs=[smear_dir,numpy_incl_path]
[87615a48]104        )
105        ]
106    )
[b72b595]107       
Note: See TracBrowser for help on using the repository browser.