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