1 | """ |
---|
2 | Installation script for SANS models |
---|
3 | """ |
---|
4 | |
---|
5 | import sys |
---|
6 | import os |
---|
7 | from numpy.distutils.misc_util import get_numpy_include_dirs |
---|
8 | numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy") |
---|
9 | |
---|
10 | # Then build and install the modules |
---|
11 | from distutils.core import Extension, setup |
---|
12 | #from setuptools import setup#, find_packages |
---|
13 | |
---|
14 | # Build the module name |
---|
15 | srcdir = os.path.join("src", "sans", "models", "c_extensions") |
---|
16 | igordir = os.path.join("src","sans", "models", "libigor") |
---|
17 | c_model_dir = os.path.join("src", "sans", "models", "c_models") |
---|
18 | smear_dir = os.path.join("src", "sans", "models", "c_smearer") |
---|
19 | print "Installing SANS models" |
---|
20 | |
---|
21 | |
---|
22 | IGNORED_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", |
---|
32 | "wrapping.py" |
---|
33 | ] |
---|
34 | if not os.name=='nt': |
---|
35 | IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"]) |
---|
36 | |
---|
37 | EXTENSIONS = [".c", ".cpp"] |
---|
38 | |
---|
39 | def 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) |
---|
46 | if ext.lower() in EXTENSIONS and f not in IGNORED_FILES: |
---|
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) |
---|
54 | if ext.lower() in EXTENSIONS and\ |
---|
55 | new_f not in IGNORED_FILES: |
---|
56 | file_list.append(os.path.join(sub_dir, new_f)) |
---|
57 | |
---|
58 | model_sources = [] |
---|
59 | append_file(file_list=model_sources, dir_path=srcdir) |
---|
60 | append_file(file_list=model_sources, dir_path=igordir) |
---|
61 | append_file(file_list=model_sources, dir_path=c_model_dir) |
---|
62 | smear_sources = [] |
---|
63 | append_file(file_list=smear_sources, dir_path=smear_dir) |
---|
64 | |
---|
65 | |
---|
66 | smearer_sources = [os.path.join(smear_dir, "smearer.cpp"), |
---|
67 | os.path.join(smear_dir, "smearer_module.cpp")] |
---|
68 | if os.name=='nt': |
---|
69 | smearer_sources.append(os.path.join(igordir, "winFuncs.c")) |
---|
70 | |
---|
71 | dist = setup( |
---|
72 | name="sansmodels", |
---|
73 | version = "1.0.0", |
---|
74 | description = "Python module for SANS scattering models", |
---|
75 | author = "SANS/DANSE", |
---|
76 | author_email = "sansdanse@gmail.gov", |
---|
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 |
---|
83 | package_dir = {"sans":os.path.join("src", "sans"), |
---|
84 | "sans.models":os.path.join("src", "sans", "models"), |
---|
85 | "sans.models.sans_extension":srcdir, |
---|
86 | }, |
---|
87 | package_data={'sans.models': [os.path.join('media', "*")]}, |
---|
88 | packages = ["sans","sans.models", |
---|
89 | "sans.models.sans_extension",], |
---|
90 | |
---|
91 | ext_modules = [ Extension("sans.models.sans_extension.c_models", |
---|
92 | sources=model_sources, |
---|
93 | |
---|
94 | include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]), |
---|
95 | # Smearer extension |
---|
96 | Extension("sans.models.sans_extension.smearer", |
---|
97 | sources = smearer_sources, |
---|
98 | include_dirs=[smear_dir, numpy_incl_path]), |
---|
99 | Extension("sans.models.sans_extension.smearer2d_helper", |
---|
100 | sources = [os.path.join(smear_dir, |
---|
101 | "smearer2d_helper_module.cpp"), |
---|
102 | os.path.join(smear_dir, "smearer2d_helper.cpp"),], |
---|
103 | include_dirs=[smear_dir,numpy_incl_path] |
---|
104 | ) |
---|
105 | ] |
---|
106 | ) |
---|
107 | |
---|