[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", |
---|
| 32 | "wrapping.py", |
---|
| 33 | "winFuncs.c"] |
---|
[0f282a5] | 34 | EXTENSIONS = [".c", ".cpp"] |
---|
[0a51f0d8] | 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) |
---|
[0f282a5] | 43 | if ext.lower() in EXTENSIONS and f not in IGNORED_FILES: |
---|
[0a51f0d8] | 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) |
---|
[0f282a5] | 51 | if ext.lower() in EXTENSIONS and\ |
---|
[0a51f0d8] | 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 | |
---|
[87615a48] | 63 | dist = setup( |
---|
[5953b77] | 64 | name="sansmodels", |
---|
[a2898df] | 65 | version = "1.0.0", |
---|
[ae3ce4e] | 66 | description = "Python module for SANS scattering models", |
---|
[87615a48] | 67 | author = "SANS/DANSE", |
---|
| 68 | author_email = "sansdanse@gmail.gov", |
---|
[ae3ce4e] | 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 |
---|
[0a51f0d8] | 75 | package_dir = {"sans":os.path.join("src", "sans"), |
---|
| 76 | "sans.models":os.path.join("src", "sans", "models"), |
---|
| 77 | "sans.models.sans_extension":srcdir, |
---|
[42c974f] | 78 | }, |
---|
| 79 | package_data={'sans.models': [os.path.join('media', "*")]}, |
---|
| 80 | packages = ["sans","sans.models", |
---|
[0abf7bf] | 81 | "sans.models.sans_extension",], |
---|
[ae3ce4e] | 82 | |
---|
[c089120] | 83 | ext_modules = [ Extension("sans.models.sans_extension.c_models", |
---|
[0a51f0d8] | 84 | sources=model_sources, |
---|
| 85 | |
---|
| 86 | include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path]), |
---|
[87615a48] | 87 | # Smearer extension |
---|
[c089120] | 88 | Extension("sans.models.sans_extension.smearer", |
---|
[0a51f0d8] | 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]), |
---|
[c089120] | 93 | Extension("sans.models.sans_extension.smearer2d_helper", |
---|
[0a51f0d8] | 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] |
---|
[87615a48] | 98 | ) |
---|
| 99 | ] |
---|
| 100 | ) |
---|
[b72b595] | 101 | |
---|