[ae3ce4e] | 1 | """ |
---|
| 2 | Installation script for SANS models |
---|
| 3 | """ |
---|
[d7a2531] | 4 | |
---|
[f88624d] | 5 | import sys |
---|
| 6 | import os |
---|
[b72b595] | 7 | from numpy.distutils.misc_util import get_numpy_include_dirs |
---|
[6c13861] | 8 | numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy") |
---|
[0abf7bf] | 9 | |
---|
[ae3ce4e] | 10 | # Then build and install the modules |
---|
[87615a48] | 11 | from distutils.core import Extension, setup |
---|
| 12 | #from setuptools import setup#, find_packages |
---|
[ae3ce4e] | 13 | |
---|
| 14 | # Build the module name |
---|
[0a51f0d8] | 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") |
---|
[ae3ce4e] | 19 | print "Installing SANS models" |
---|
| 20 | |
---|
| 21 | |
---|
[0a51f0d8] | 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", |
---|
[f9303b6] | 32 | "wrapping.py" |
---|
| 33 | ] |
---|
| 34 | if not os.name=='nt': |
---|
| 35 | IGNORED_FILES.extend(["gamma_win.c","winFuncs.c"]) |
---|
| 36 | |
---|
[0f282a5] | 37 | EXTENSIONS = [".c", ".cpp"] |
---|
[0a51f0d8] | 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) |
---|
[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 | |
---|
| 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 | |
---|
[f9303b6] | 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 | |
---|
[87615a48] | 71 | dist = 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 | |
---|