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 | "winFuncs.c"] |
---|
34 | EXTENSIONS = [".c", ".cpp"] |
---|
35 | |
---|
36 | def append_file(file_list, dir_path): |
---|
37 | """ |
---|
38 | Add sources file to sources |
---|
39 | """ |
---|
40 | for f in os.listdir(dir_path): |
---|
41 | if os.path.isfile(os.path.join(dir_path, f)): |
---|
42 | _, ext = os.path.splitext(f) |
---|
43 | if ext.lower() in EXTENSIONS and f not in IGNORED_FILES: |
---|
44 | file_list.append(os.path.join(dir_path, f)) |
---|
45 | elif os.path.isdir(os.path.join(dir_path, f)) and \ |
---|
46 | not f.startswith("."): |
---|
47 | sub_dir = os.path.join(dir_path, f) |
---|
48 | for new_f in os.listdir(sub_dir): |
---|
49 | if os.path.isfile(os.path.join(sub_dir, new_f)): |
---|
50 | _, ext = os.path.splitext(new_f) |
---|
51 | if ext.lower() in EXTENSIONS and\ |
---|
52 | new_f not in IGNORED_FILES: |
---|
53 | file_list.append(os.path.join(sub_dir, new_f)) |
---|
54 | |
---|
55 | model_sources = [] |
---|
56 | append_file(file_list=model_sources, dir_path=srcdir) |
---|
57 | append_file(file_list=model_sources, dir_path=igordir) |
---|
58 | append_file(file_list=model_sources, dir_path=c_model_dir) |
---|
59 | smear_sources = [] |
---|
60 | append_file(file_list=smear_sources, dir_path=smear_dir) |
---|
61 | |
---|
62 | |
---|
63 | dist = setup( |
---|
64 | name="sansmodels", |
---|
65 | version = "1.0.0", |
---|
66 | description = "Python module for SANS scattering models", |
---|
67 | author = "SANS/DANSE", |
---|
68 | author_email = "sansdanse@gmail.gov", |
---|
69 | url = "http://danse.us/trac/sans", |
---|
70 | |
---|
71 | # Place this module under the sans package |
---|
72 | #ext_package = "sans", |
---|
73 | |
---|
74 | # Use the pure python modules |
---|
75 | package_dir = {"sans":os.path.join("src", "sans"), |
---|
76 | "sans.models":os.path.join("src", "sans", "models"), |
---|
77 | "sans.models.sans_extension":srcdir, |
---|
78 | }, |
---|
79 | package_data={'sans.models': [os.path.join('media', "*")]}, |
---|
80 | packages = ["sans","sans.models", |
---|
81 | "sans.models.sans_extension",], |
---|
82 | |
---|
83 | ext_modules = [ Extension("sans.models.sans_extension.c_models", |
---|
84 | sources=model_sources, |
---|
85 | |
---|
86 | include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]), |
---|
87 | # Smearer extension |
---|
88 | Extension("sans.models.sans_extension.smearer", |
---|
89 | sources = [os.path.join(smear_dir, |
---|
90 | "smearer.cpp"), |
---|
91 | os.path.join(smear_dir, "smearer_module.cpp"),], |
---|
92 | include_dirs=[smear_dir, numpy_incl_path]), |
---|
93 | Extension("sans.models.sans_extension.smearer2d_helper", |
---|
94 | sources = [os.path.join(smear_dir, |
---|
95 | "smearer2d_helper_module.cpp"), |
---|
96 | os.path.join(smear_dir, "smearer2d_helper.cpp"),], |
---|
97 | include_dirs=[smear_dir,numpy_incl_path] |
---|
98 | ) |
---|
99 | ] |
---|
100 | ) |
---|
101 | |
---|