[f36e01f] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | #!/usr/bin/env python |
---|
| 3 | |
---|
[d6bc28cf] | 4 | """ |
---|
[c329f4d] | 5 | Setup for SasView |
---|
[f36e01f] | 6 | TODO: Add checks to see that all the dependencies are on the system |
---|
[d6bc28cf] | 7 | """ |
---|
[d66dbcc] | 8 | from __future__ import print_function |
---|
[f36e01f] | 9 | |
---|
[d6bc28cf] | 10 | import os |
---|
[6c7e4cc1] | 11 | import subprocess |
---|
[c8843be] | 12 | import shutil |
---|
[f36e01f] | 13 | import sys |
---|
[2cef9d3] | 14 | from distutils.command.build_ext import build_ext |
---|
[968aa6e] | 15 | from distutils.core import Command |
---|
[d6bc28cf] | 16 | |
---|
[9a5097c] | 17 | import numpy as np |
---|
[f36e01f] | 18 | from setuptools import Extension, setup |
---|
[d6bc28cf] | 19 | |
---|
[95d7c4f] | 20 | if os.name == 'nt': |
---|
| 21 | try: |
---|
| 22 | import tinycc |
---|
| 23 | except ImportError: |
---|
| 24 | os.path.insert(os.path.insert(0, '..', 'tinycc')) |
---|
| 25 | import tinycc |
---|
| 26 | use_tinycc = True |
---|
| 27 | sys.argv.append('--compiler=mingw32') |
---|
| 28 | print(tinycc.TCC) |
---|
| 29 | else: |
---|
| 30 | use_tinycc = False |
---|
| 31 | |
---|
[5548954] | 32 | # Manage version number ###################################### |
---|
[efe730d] | 33 | with open(os.path.join("src", "sas", "sasview", "__init__.py")) as fid: |
---|
| 34 | for line in fid: |
---|
| 35 | if line.startswith('__version__'): |
---|
| 36 | VERSION = line.split('"')[1] |
---|
| 37 | break |
---|
| 38 | else: |
---|
| 39 | raise ValueError("Could not find version in src/sas/sasview/__init__.py") |
---|
[5548954] | 40 | ############################################################## |
---|
| 41 | |
---|
[d6bc28cf] | 42 | package_dir = {} |
---|
| 43 | package_data = {} |
---|
| 44 | packages = [] |
---|
| 45 | ext_modules = [] |
---|
| 46 | |
---|
[8ab3302] | 47 | # Remove all files that should be updated by this setup |
---|
[3a39c2e] | 48 | # We do this here because application updates these files from .sasview |
---|
[8ab3302] | 49 | # except when there is no such file |
---|
| 50 | # Todo : make this list generic |
---|
[f36e01f] | 51 | # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', |
---|
[a62945e] | 52 | # 'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', |
---|
| 53 | # 'testmodel_2.py', 'testmodel.py', |
---|
| 54 | # 'polynominal5.pyc', 'sph_bessel_jn.pyc', |
---|
| 55 | # 'sum_Ap1_1_Ap2.pyc', 'sum_p1_p2.pyc', |
---|
| 56 | # 'testmodel_2.pyc', 'testmodel.pyc', 'plugins.log'] |
---|
[c8843be] | 57 | |
---|
| 58 | CURRENT_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
---|
| 59 | SASVIEW_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build") |
---|
| 60 | |
---|
[914ba0a] | 61 | # TODO: build step should not be messing with existing installation!! |
---|
[f36e01f] | 62 | sas_dir = os.path.join(os.path.expanduser("~"), '.sasview') |
---|
[3a39c2e] | 63 | if os.path.isdir(sas_dir): |
---|
| 64 | f_path = os.path.join(sas_dir, "sasview.log") |
---|
[e615a0d] | 65 | if os.path.isfile(f_path): |
---|
| 66 | os.remove(f_path) |
---|
[50008e3] | 67 | f_path = os.path.join(sas_dir, "categories.json") |
---|
[ea5fa58] | 68 | if os.path.isfile(f_path): |
---|
| 69 | os.remove(f_path) |
---|
[3a39c2e] | 70 | f_path = os.path.join(sas_dir, 'config', "custom_config.py") |
---|
[e615a0d] | 71 | if os.path.isfile(f_path): |
---|
| 72 | os.remove(f_path) |
---|
[5881b17] | 73 | #f_path = os.path.join(sas_dir, 'plugin_models') |
---|
[f36e01f] | 74 | # if os.path.isdir(f_path): |
---|
[a62945e] | 75 | # for f in os.listdir(f_path): |
---|
| 76 | # if f in plugin_model_list: |
---|
| 77 | # file_path = os.path.join(f_path, f) |
---|
| 78 | # os.remove(file_path) |
---|
[899e084] | 79 | |
---|
[f542866] | 80 | |
---|
| 81 | # Optionally clean before build. |
---|
| 82 | dont_clean = 'update' in sys.argv |
---|
| 83 | if dont_clean: |
---|
| 84 | sys.argv.remove('update') |
---|
| 85 | elif os.path.exists(SASVIEW_BUILD): |
---|
[d66dbcc] | 86 | print("Removing existing build directory", SASVIEW_BUILD, "for a clean build") |
---|
[899e084] | 87 | shutil.rmtree(SASVIEW_BUILD) |
---|
[18e7309] | 88 | |
---|
[e615a0d] | 89 | # 'sys.maxsize' and 64bit: Not supported for python2.5 |
---|
[899e084] | 90 | is_64bits = sys.maxsize > 2**32 |
---|
[e79a467] | 91 | |
---|
[7a04dbb] | 92 | enable_openmp = False |
---|
[f36e01f] | 93 | if sys.platform == 'darwin': |
---|
[f468791] | 94 | if not is_64bits: |
---|
| 95 | # Disable OpenMP |
---|
| 96 | enable_openmp = False |
---|
| 97 | else: |
---|
| 98 | # Newer versions of Darwin don't support openmp |
---|
| 99 | try: |
---|
| 100 | darwin_ver = int(os.uname()[2].split('.')[0]) |
---|
| 101 | if darwin_ver >= 12: |
---|
| 102 | enable_openmp = False |
---|
| 103 | except: |
---|
[f3bf622] | 104 | print("PROBLEM determining Darwin version") |
---|
[b30ed8f] | 105 | |
---|
| 106 | # Options to enable OpenMP |
---|
[f36e01f] | 107 | copt = {'msvc': ['/openmp'], |
---|
| 108 | 'mingw32': ['-fopenmp'], |
---|
| 109 | 'unix': ['-fopenmp']} |
---|
| 110 | lopt = {'msvc': ['/MANIFEST'], |
---|
| 111 | 'mingw32': ['-fopenmp'], |
---|
| 112 | 'unix': ['-lgomp']} |
---|
[13f00a0] | 113 | |
---|
[ebdb833] | 114 | # Platform-specific link options |
---|
[f36e01f] | 115 | platform_lopt = {'msvc': ['/MANIFEST']} |
---|
[307fa4f] | 116 | platform_copt = {} |
---|
[b9c8fc5] | 117 | |
---|
| 118 | # Set copts to get compile working on OS X >= 10.9 using clang |
---|
[f36e01f] | 119 | if sys.platform == 'darwin': |
---|
[b9c8fc5] | 120 | try: |
---|
| 121 | darwin_ver = int(os.uname()[2].split('.')[0]) |
---|
[4adf48e] | 122 | if darwin_ver >= 13 and darwin_ver < 14: |
---|
[f36e01f] | 123 | platform_copt = { |
---|
| 124 | 'unix': ['-Wno-error=unused-command-line-argument-hard-error-in-future']} |
---|
[b9c8fc5] | 125 | except: |
---|
[f3bf622] | 126 | print("PROBLEM determining Darwin version") |
---|
[b9c8fc5] | 127 | |
---|
| 128 | |
---|
[5972029] | 129 | class DisableOpenMPCommand(Command): |
---|
| 130 | description = "The version of MinGW that comes with Anaconda does not come with OpenMP :( "\ |
---|
| 131 | "This commands means we can turn off compiling with OpenMP for this or any "\ |
---|
| 132 | "other reason." |
---|
| 133 | user_options = [] |
---|
| 134 | |
---|
| 135 | def initialize_options(self): |
---|
| 136 | self.cwd = None |
---|
| 137 | |
---|
| 138 | def finalize_options(self): |
---|
| 139 | self.cwd = os.getcwd() |
---|
| 140 | global enable_openmp |
---|
| 141 | enable_openmp = False |
---|
[1829835] | 142 | |
---|
[5972029] | 143 | def run(self): |
---|
| 144 | pass |
---|
[ebdb833] | 145 | |
---|
[f36e01f] | 146 | |
---|
| 147 | class build_ext_subclass(build_ext): |
---|
[13f00a0] | 148 | def build_extensions(self): |
---|
[95d7c4f] | 149 | if use_tinycc: |
---|
| 150 | # Note: no -O option because not an optimizer |
---|
| 151 | self.compiler.set_executables( |
---|
| 152 | #archiver = ['ar', '-cr'], |
---|
| 153 | compiler=[tinycc.TCC, '-DMS_WIN64', '-D__TINYCC__', '-Wall'], |
---|
| 154 | #compiler_cxx=['g__', '-DMS_WIN64', '-Wall'], # tinycc is not a C++ compiler |
---|
| 155 | compiler_so=[tinycc.TCC, '-DMS_WIN64', '-D__TINYCC__', '-Wall'], # and '-c'?? |
---|
| 156 | #dll_libraries=['msvcr90'], |
---|
| 157 | linker_exe=[tinycc.TCC, '-DMS_WIN64'], |
---|
| 158 | linker_so=[tinycc.TCC, '-DMS_WIN64', '-shared'], |
---|
| 159 | #linker_dll=tinycc.TCC, |
---|
| 160 | ) |
---|
| 161 | sysroot = os.path.dirname(os.path.realpath(sys.executable)) |
---|
| 162 | self.compiler.include_dirs = [os.path.join(sysroot, 'include')] |
---|
| 163 | self.compiler.library_dirs = [sysroot] |
---|
[13f00a0] | 164 | # Get 64-bitness |
---|
| 165 | c = self.compiler.compiler_type |
---|
[f3bf622] | 166 | print("Compiling with %s (64bit=%s)" % (c, str(is_64bits))) |
---|
[95d7c4f] | 167 | #print("=== compiler attributes ===") |
---|
| 168 | #print("\n".join("%s: %s"%(k, v) for k, v in sorted(self.compiler.__dict__.items()))) |
---|
| 169 | #print("=== build_ext attributes ===") |
---|
| 170 | #print("\n".join("%s: %s"%(k, v) for k, v in self.__dict__.items())) |
---|
| 171 | #sys.exit(1) |
---|
[18e7309] | 172 | |
---|
[ebdb833] | 173 | # OpenMP build options |
---|
[b30ed8f] | 174 | if enable_openmp: |
---|
[f3bf622] | 175 | if c in copt: |
---|
[5980b1a] | 176 | for e in self.extensions: |
---|
[f36e01f] | 177 | e.extra_compile_args = copt[c] |
---|
[f3bf622] | 178 | if c in lopt: |
---|
[13f00a0] | 179 | for e in self.extensions: |
---|
[f36e01f] | 180 | e.extra_link_args = lopt[c] |
---|
[18e7309] | 181 | |
---|
[ebdb833] | 182 | # Platform-specific build options |
---|
[f3bf622] | 183 | if c in platform_lopt: |
---|
[ebdb833] | 184 | for e in self.extensions: |
---|
[f36e01f] | 185 | e.extra_link_args = platform_lopt[c] |
---|
[ebdb833] | 186 | |
---|
[f3bf622] | 187 | if c in platform_copt: |
---|
[1829835] | 188 | for e in self.extensions: |
---|
[f36e01f] | 189 | e.extra_compile_args = platform_copt[c] |
---|
[1829835] | 190 | |
---|
[13f00a0] | 191 | build_ext.build_extensions(self) |
---|
[d6bc28cf] | 192 | |
---|
[f36e01f] | 193 | |
---|
[968aa6e] | 194 | class BuildSphinxCommand(Command): |
---|
| 195 | description = "Build Sphinx documentation." |
---|
| 196 | user_options = [] |
---|
| 197 | |
---|
| 198 | def initialize_options(self): |
---|
| 199 | self.cwd = None |
---|
| 200 | |
---|
| 201 | def finalize_options(self): |
---|
| 202 | self.cwd = os.getcwd() |
---|
| 203 | |
---|
[d8c4019] | 204 | def run(self): |
---|
[115eb7e] | 205 | ''' First builds the sasmodels documentation if the directory |
---|
| 206 | is present. Then builds the sasview docs. |
---|
| 207 | ''' |
---|
| 208 | ### AJJ - Add code for building sasmodels docs here: |
---|
| 209 | # check for doc path |
---|
[14bb7a4] | 210 | SASMODELS_DOCPATH = os.path.abspath(os.path.join(os.getcwd(), '..', 'sasmodels', 'doc')) |
---|
| 211 | print("========= check for sasmodels at", SASMODELS_DOCPATH, "============") |
---|
[6c7e4cc1] | 212 | if os.path.exists(SASMODELS_DOCPATH): |
---|
| 213 | if os.path.isdir(SASMODELS_DOCPATH): |
---|
[115eb7e] | 214 | # if available, build sasmodels docs |
---|
[21bba86] | 215 | print("============= Building sasmodels model documentation ===============") |
---|
[14bb7a4] | 216 | smdocbuild = subprocess.call(["make", "-C", SASMODELS_DOCPATH, "html"]) |
---|
[6c7e4cc1] | 217 | else: |
---|
| 218 | # if not available warning message |
---|
[21bba86] | 219 | print("== !!WARNING!! sasmodels directory not found. Cannot build model docs. ==") |
---|
[115eb7e] | 220 | |
---|
| 221 | #Now build sasview (+sasmodels) docs |
---|
[d8c4019] | 222 | sys.path.append("docs/sphinx-docs") |
---|
| 223 | import build_sphinx |
---|
[c2ee2b1] | 224 | build_sphinx.rebuild() |
---|
[968aa6e] | 225 | |
---|
[f36e01f] | 226 | |
---|
[3a39c2e] | 227 | # sas module |
---|
| 228 | package_dir["sas"] = os.path.join("src", "sas") |
---|
| 229 | packages.append("sas") |
---|
[29e96f3] | 230 | |
---|
[e0bbb7c] | 231 | # sas module |
---|
| 232 | package_dir["sas.sasgui"] = os.path.join("src", "sas", "sasgui") |
---|
| 233 | packages.append("sas.sasgui") |
---|
| 234 | |
---|
| 235 | # sas module |
---|
| 236 | package_dir["sas.sascalc"] = os.path.join("src", "sas", "sascalc") |
---|
| 237 | packages.append("sas.sascalc") |
---|
| 238 | |
---|
| 239 | # sas.sascalc.invariant |
---|
[f36e01f] | 240 | package_dir["sas.sascalc.invariant"] = os.path.join( |
---|
| 241 | "src", "sas", "sascalc", "invariant") |
---|
[e0bbb7c] | 242 | packages.extend(["sas.sascalc.invariant"]) |
---|
[d6bc28cf] | 243 | |
---|
[d85c194] | 244 | # sas.sasgui.guiframe |
---|
| 245 | guiframe_path = os.path.join("src", "sas", "sasgui", "guiframe") |
---|
| 246 | package_dir["sas.sasgui.guiframe"] = guiframe_path |
---|
[f36e01f] | 247 | package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join( |
---|
| 248 | os.path.join(guiframe_path, "local_perspectives")) |
---|
[d85c194] | 249 | package_data["sas.sasgui.guiframe"] = ['images/*', 'media/*'] |
---|
[f36e01f] | 250 | packages.extend( |
---|
| 251 | ["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) |
---|
[d6bc28cf] | 252 | # build local plugin |
---|
[5980b1a] | 253 | for d in os.listdir(os.path.join(guiframe_path, "local_perspectives")): |
---|
[f36e01f] | 254 | if d not in ['.svn', '__init__.py', '__init__.pyc']: |
---|
[d85c194] | 255 | package_name = "sas.sasgui.guiframe.local_perspectives." + d |
---|
[3d24489] | 256 | packages.append(package_name) |
---|
[f36e01f] | 257 | package_dir[package_name] = os.path.join( |
---|
| 258 | guiframe_path, "local_perspectives", d) |
---|
[d6bc28cf] | 259 | |
---|
[e0bbb7c] | 260 | # sas.sascalc.dataloader |
---|
[f36e01f] | 261 | package_dir["sas.sascalc.dataloader"] = os.path.join( |
---|
| 262 | "src", "sas", "sascalc", "dataloader") |
---|
[7a5d066] | 263 | package_data["sas.sascalc.dataloader.readers"] = ['schema/*.xsd'] |
---|
[f36e01f] | 264 | packages.extend(["sas.sascalc.dataloader", "sas.sascalc.dataloader.readers", |
---|
| 265 | "sas.sascalc.dataloader.readers.schema"]) |
---|
[d6bc28cf] | 266 | |
---|
| 267 | |
---|
[e0bbb7c] | 268 | # sas.sascalc.calculator |
---|
[9e531f2] | 269 | gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") |
---|
| 270 | package_dir["sas.sascalc.calculator.core"] = gen_dir |
---|
[f36e01f] | 271 | package_dir["sas.sascalc.calculator"] = os.path.join( |
---|
| 272 | "src", "sas", "sascalc", "calculator") |
---|
| 273 | packages.extend(["sas.sascalc.calculator", "sas.sascalc.calculator.core"]) |
---|
| 274 | ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i", |
---|
| 275 | sources=[ |
---|
[0957bb3a] | 276 | os.path.join(gen_dir, "sld2i_module.c"), |
---|
| 277 | os.path.join(gen_dir, "sld2i.c"), |
---|
[f36e01f] | 278 | os.path.join(gen_dir, "libfunc.c"), |
---|
| 279 | os.path.join(gen_dir, "librefl.c"), |
---|
| 280 | ], |
---|
| 281 | include_dirs=[gen_dir], |
---|
| 282 | ) |
---|
| 283 | ) |
---|
[9e531f2] | 284 | |
---|
[b699768] | 285 | # sas.sascalc.pr |
---|
[f36e01f] | 286 | srcdir = os.path.join("src", "sas", "sascalc", "pr", "c_extensions") |
---|
[b699768] | 287 | package_dir["sas.sascalc.pr.core"] = srcdir |
---|
[f36e01f] | 288 | package_dir["sas.sascalc.pr"] = os.path.join("src", "sas", "sascalc", "pr") |
---|
| 289 | packages.extend(["sas.sascalc.pr", "sas.sascalc.pr.core"]) |
---|
| 290 | ext_modules.append(Extension("sas.sascalc.pr.core.pr_inversion", |
---|
| 291 | sources=[os.path.join(srcdir, "Cinvertor.c"), |
---|
| 292 | os.path.join(srcdir, "invertor.c"), |
---|
| 293 | ], |
---|
| 294 | include_dirs=[], |
---|
| 295 | )) |
---|
[18e7309] | 296 | |
---|
| 297 | |
---|
| 298 | # sas.sascalc.file_converter |
---|
| 299 | mydir = os.path.join("src", "sas", "sascalc", "file_converter", "c_ext") |
---|
| 300 | package_dir["sas.sascalc.file_converter.core"] = mydir |
---|
[f36e01f] | 301 | package_dir["sas.sascalc.file_converter"] = os.path.join( |
---|
| 302 | "src", "sas", "sascalc", "file_converter") |
---|
| 303 | packages.extend(["sas.sascalc.file_converter", |
---|
| 304 | "sas.sascalc.file_converter.core"]) |
---|
| 305 | ext_modules.append(Extension("sas.sascalc.file_converter.core.bsl_loader", |
---|
| 306 | sources=[os.path.join(mydir, "bsl_loader.c")], |
---|
| 307 | include_dirs=[np.get_include()], |
---|
| 308 | )) |
---|
| 309 | |
---|
| 310 | # sas.sascalc.corfunc |
---|
| 311 | package_dir["sas.sascalc.corfunc"] = os.path.join( |
---|
| 312 | "src", "sas", "sascalc", "corfunc") |
---|
[b854587] | 313 | |
---|
[1e13b53] | 314 | packages.extend(["sas.sascalc.corfunc"]) |
---|
| 315 | |
---|
[b699768] | 316 | # sas.sascalc.fit |
---|
| 317 | package_dir["sas.sascalc.fit"] = os.path.join("src", "sas", "sascalc", "fit") |
---|
| 318 | packages.append("sas.sascalc.fit") |
---|
[3d24489] | 319 | |
---|
| 320 | # Perspectives |
---|
[f36e01f] | 321 | package_dir["sas.sasgui.perspectives"] = os.path.join( |
---|
| 322 | "src", "sas", "sasgui", "perspectives") |
---|
| 323 | package_dir["sas.sasgui.perspectives.pr"] = os.path.join( |
---|
| 324 | "src", "sas", "sasgui", "perspectives", "pr") |
---|
| 325 | packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.pr"]) |
---|
[1e13b53] | 326 | package_data["sas.sasgui.perspectives.pr"] = ['media/*'] |
---|
[d85c194] | 327 | |
---|
[f36e01f] | 328 | package_dir["sas.sasgui.perspectives.invariant"] = os.path.join( |
---|
| 329 | "src", "sas", "sasgui", "perspectives", "invariant") |
---|
[d85c194] | 330 | packages.extend(["sas.sasgui.perspectives.invariant"]) |
---|
[f36e01f] | 331 | package_data['sas.sasgui.perspectives.invariant'] = [ |
---|
| 332 | os.path.join("media", '*')] |
---|
| 333 | |
---|
| 334 | package_dir["sas.sasgui.perspectives.fitting"] = os.path.join( |
---|
| 335 | "src", "sas", "sasgui", "perspectives", "fitting") |
---|
| 336 | package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join( |
---|
| 337 | "src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") |
---|
| 338 | packages.extend(["sas.sasgui.perspectives.fitting", |
---|
| 339 | "sas.sasgui.perspectives.fitting.plugin_models"]) |
---|
| 340 | package_data['sas.sasgui.perspectives.fitting'] = [ |
---|
| 341 | 'media/*', 'plugin_models/*'] |
---|
| 342 | |
---|
| 343 | packages.extend(["sas.sasgui.perspectives", |
---|
| 344 | "sas.sasgui.perspectives.calculator"]) |
---|
[d85c194] | 345 | package_data['sas.sasgui.perspectives.calculator'] = ['images/*', 'media/*'] |
---|
| 346 | |
---|
[f36e01f] | 347 | package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join( |
---|
| 348 | "src", "sas", "sasgui", "perspectives", "corfunc") |
---|
[1e13b53] | 349 | packages.extend(["sas.sasgui.perspectives.corfunc"]) |
---|
| 350 | package_data['sas.sasgui.perspectives.corfunc'] = ['media/*'] |
---|
| 351 | |
---|
[f36e01f] | 352 | package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join( |
---|
| 353 | "src", "sas", "sasgui", "perspectives", "file_converter") |
---|
[1e13b53] | 354 | packages.extend(["sas.sasgui.perspectives.file_converter"]) |
---|
| 355 | package_data['sas.sasgui.perspectives.file_converter'] = ['media/*'] |
---|
[d85c194] | 356 | |
---|
[d6bc28cf] | 357 | # Data util |
---|
[f36e01f] | 358 | package_dir["sas.sascalc.data_util"] = os.path.join( |
---|
| 359 | "src", "sas", "sascalc", "data_util") |
---|
[b699768] | 360 | packages.append("sas.sascalc.data_util") |
---|
[d6bc28cf] | 361 | |
---|
| 362 | # Plottools |
---|
[f36e01f] | 363 | package_dir["sas.sasgui.plottools"] = os.path.join( |
---|
| 364 | "src", "sas", "sasgui", "plottools") |
---|
[d7bb526] | 365 | packages.append("sas.sasgui.plottools") |
---|
[d6bc28cf] | 366 | |
---|
[9274711] | 367 | # # Last of the sas.models |
---|
| 368 | # package_dir["sas.models"] = os.path.join("src", "sas", "models") |
---|
| 369 | # packages.append("sas.models") |
---|
[2d1b700] | 370 | |
---|
[d6bc28cf] | 371 | EXTENSIONS = [".c", ".cpp"] |
---|
| 372 | |
---|
[f36e01f] | 373 | |
---|
[d6bc28cf] | 374 | def append_file(file_list, dir_path): |
---|
| 375 | """ |
---|
| 376 | Add sources file to sources |
---|
| 377 | """ |
---|
| 378 | for f in os.listdir(dir_path): |
---|
| 379 | if os.path.isfile(os.path.join(dir_path, f)): |
---|
| 380 | _, ext = os.path.splitext(f) |
---|
[4c29e4d] | 381 | if ext.lower() in EXTENSIONS: |
---|
[9e531f2] | 382 | file_list.append(os.path.join(dir_path, f)) |
---|
[d6bc28cf] | 383 | elif os.path.isdir(os.path.join(dir_path, f)) and \ |
---|
| 384 | not f.startswith("."): |
---|
| 385 | sub_dir = os.path.join(dir_path, f) |
---|
| 386 | for new_f in os.listdir(sub_dir): |
---|
| 387 | if os.path.isfile(os.path.join(sub_dir, new_f)): |
---|
| 388 | _, ext = os.path.splitext(new_f) |
---|
[4c29e4d] | 389 | if ext.lower() in EXTENSIONS: |
---|
[9e531f2] | 390 | file_list.append(os.path.join(sub_dir, new_f)) |
---|
[820df88] | 391 | |
---|
[f36e01f] | 392 | |
---|
[820df88] | 393 | # Comment out the following to avoid rebuilding all the models |
---|
[9e531f2] | 394 | file_sources = [] |
---|
| 395 | append_file(file_sources, gen_dir) |
---|
[820df88] | 396 | |
---|
[f36e01f] | 397 | # Wojtek's hacky way to add doc files while bundling egg |
---|
| 398 | # def add_doc_files(directory): |
---|
[5881b17] | 399 | # paths = [] |
---|
| 400 | # for (path, directories, filenames) in os.walk(directory): |
---|
| 401 | # for filename in filenames: |
---|
| 402 | # paths.append(os.path.join(path, filename)) |
---|
| 403 | # return paths |
---|
| 404 | |
---|
| 405 | #doc_files = add_doc_files('doc') |
---|
| 406 | |
---|
[c329f4d] | 407 | # SasView |
---|
[ed03b99] | 408 | package_data['sas'] = ['logging.ini'] |
---|
[5881b17] | 409 | package_data['sas.sasview'] = ['images/*', |
---|
[bbb8a56] | 410 | 'media/*', |
---|
[d4c88e24] | 411 | 'test/*.txt', |
---|
[bbb8a56] | 412 | 'test/1d_data/*', |
---|
| 413 | 'test/2d_data/*', |
---|
[27109e5] | 414 | 'test/convertible_files/*', |
---|
| 415 | 'test/coordinate_data/*', |
---|
| 416 | 'test/image_data/*', |
---|
| 417 | 'test/media/*', |
---|
| 418 | 'test/other_files/*', |
---|
[bbb8a56] | 419 | 'test/save_states/*', |
---|
[7152c82] | 420 | 'test/sesans_data/*', |
---|
| 421 | 'test/upcoming_formats/*', |
---|
[27109e5] | 422 | ] |
---|
[3a39c2e] | 423 | packages.append("sas.sasview") |
---|
[d6bc28cf] | 424 | |
---|
[9f32c57] | 425 | required = [ |
---|
[36ca21e] | 426 | 'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing<2.0.0', |
---|
[9f32c57] | 427 | |
---|
| 428 | # 'lxml>=2.2.2', |
---|
[db74ee8] | 429 | 'lxml', 'h5py', |
---|
[9f32c57] | 430 | |
---|
[f36e01f] | 431 | # The following dependecies won't install automatically, so assume them |
---|
| 432 | # The numbers should be bumped up for matplotlib and wxPython as well. |
---|
[9f32c57] | 433 | # 'numpy>=1.4.1', 'scipy>=0.7.2', 'matplotlib>=0.99.1.1', |
---|
| 434 | # 'wxPython>=2.8.11', 'pil', |
---|
[f36e01f] | 435 | ] |
---|
[213b445] | 436 | |
---|
[f36e01f] | 437 | if os.name == 'nt': |
---|
[7a211030] | 438 | required.extend(['html5lib', 'reportlab']) |
---|
[7f59928e] | 439 | else: |
---|
[775d06f] | 440 | # 'pil' is now called 'pillow' |
---|
[5f6336f] | 441 | required.extend(['pillow']) |
---|
[5881b17] | 442 | |
---|
[18e7309] | 443 | # Set up SasView |
---|
[d6bc28cf] | 444 | setup( |
---|
[c329f4d] | 445 | name="sasview", |
---|
[f36e01f] | 446 | version=VERSION, |
---|
| 447 | description="SasView application", |
---|
| 448 | author="SasView Team", |
---|
| 449 | author_email="developers@sasview.org", |
---|
| 450 | url="http://sasview.org", |
---|
| 451 | license="PSF", |
---|
| 452 | keywords="small-angle x-ray and neutron scattering analysis", |
---|
| 453 | download_url="https://github.com/SasView/sasview.git", |
---|
| 454 | package_dir=package_dir, |
---|
| 455 | packages=packages, |
---|
| 456 | package_data=package_data, |
---|
| 457 | ext_modules=ext_modules, |
---|
| 458 | install_requires=required, |
---|
| 459 | zip_safe=False, |
---|
| 460 | entry_points={ |
---|
| 461 | 'console_scripts': [ |
---|
[ae42c85] | 462 | "sasview = sas.sasview.sasview:run_gui", |
---|
[f36e01f] | 463 | ] |
---|
| 464 | }, |
---|
| 465 | cmdclass={'build_ext': build_ext_subclass, |
---|
| 466 | 'docs': BuildSphinxCommand, |
---|
| 467 | 'disable_openmp': DisableOpenMPCommand} |
---|
| 468 | ) |
---|