- Timestamp:
- May 2, 2017 1:58:01 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d66dbcc
- Parents:
- 74d9780 (diff), 658dd57 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
setup.py
r899e084 r914ba0a 1 # -*- coding: utf-8 -*- 2 #!/usr/bin/env python 3 1 4 """ 2 5 Setup for SasView 3 #TODO: Add checks to see that all the dependencies are on the system6 TODO: Add checks to see that all the dependencies are on the system 4 7 """ 8 9 import os 10 import subprocess 11 import shutil 5 12 import sys 6 import os7 import shutil8 from setuptools import setup, Extension9 13 from distutils.command.build_ext import build_ext 10 14 from distutils.core import Command 15 16 import numpy as np 17 from setuptools import Extension, setup 11 18 12 19 # Manage version number ###################################### … … 29 36 # except when there is no such file 30 37 # Todo : make this list generic 31 # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py',38 # plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 32 39 # 'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', 33 40 # 'testmodel_2.py', 'testmodel.py', … … 39 46 SASVIEW_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build") 40 47 41 sas_dir = os.path.join(os.path.expanduser("~"),'.sasview') 48 # TODO: build step should not be messing with existing installation!! 49 sas_dir = os.path.join(os.path.expanduser("~"), '.sasview') 42 50 if os.path.isdir(sas_dir): 43 51 f_path = os.path.join(sas_dir, "sasview.log") … … 51 59 os.remove(f_path) 52 60 #f_path = os.path.join(sas_dir, 'plugin_models') 53 # if os.path.isdir(f_path):61 # if os.path.isdir(f_path): 54 62 # for f in os.listdir(f_path): 55 63 # if f in plugin_model_list: … … 60 68 print "Removing existing build directory", SASVIEW_BUILD, "for a clean build" 61 69 shutil.rmtree(SASVIEW_BUILD) 62 70 63 71 # 'sys.maxsize' and 64bit: Not supported for python2.5 64 72 is_64bits = sys.maxsize > 2**32 73 65 74 enable_openmp = False 66 67 if sys.platform =='darwin': 75 if sys.platform == 'darwin': 68 76 if not is_64bits: 69 77 # Disable OpenMP … … 76 84 enable_openmp = False 77 85 except: 78 print "PROBLEM determining Darwin version"86 print("PROBLEM determining Darwin version") 79 87 80 88 # Options to enable OpenMP 81 copt = 82 'mingw32': ['-fopenmp'],83 'unix': ['-fopenmp']}84 lopt = 85 'mingw32': ['-fopenmp'],86 'unix': ['-lgomp']}89 copt = {'msvc': ['/openmp'], 90 'mingw32': ['-fopenmp'], 91 'unix': ['-fopenmp']} 92 lopt = {'msvc': ['/MANIFEST'], 93 'mingw32': ['-fopenmp'], 94 'unix': ['-lgomp']} 87 95 88 96 # Platform-specific link options 89 platform_lopt = {'msvc' 97 platform_lopt = {'msvc': ['/MANIFEST']} 90 98 platform_copt = {} 91 99 92 100 # Set copts to get compile working on OS X >= 10.9 using clang 93 if sys.platform == 'darwin':101 if sys.platform == 'darwin': 94 102 try: 95 103 darwin_ver = int(os.uname()[2].split('.')[0]) 96 104 if darwin_ver >= 13 and darwin_ver < 14: 97 platform_copt = {'unix' : ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 105 platform_copt = { 106 'unix': ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 98 107 except: 99 print "PROBLEM determining Darwin version" 108 print("PROBLEM determining Darwin version") 109 100 110 101 111 class DisableOpenMPCommand(Command): … … 116 126 pass 117 127 118 class build_ext_subclass( build_ext ): 128 129 class build_ext_subclass(build_ext): 119 130 def build_extensions(self): 120 131 # Get 64-bitness 121 132 c = self.compiler.compiler_type 122 print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))123 133 print("Compiling with %s (64bit=%s)" % (c, str(is_64bits))) 134 124 135 # OpenMP build options 125 136 if enable_openmp: 126 if c opt.has_key(c):137 if c in copt: 127 138 for e in self.extensions: 128 e.extra_compile_args = copt[ c]129 if lopt.has_key(c):139 e.extra_compile_args = copt[c] 140 if c in lopt: 130 141 for e in self.extensions: 131 e.extra_link_args = lopt[ c]132 142 e.extra_link_args = lopt[c] 143 133 144 # Platform-specific build options 134 if platform_lopt.has_key(c):145 if c in platform_lopt: 135 146 for e in self.extensions: 136 e.extra_link_args = platform_lopt[ c]137 138 if platform_copt.has_key(c):147 e.extra_link_args = platform_lopt[c] 148 149 if c in platform_copt: 139 150 for e in self.extensions: 140 e.extra_compile_args = platform_copt[ c ] 141 151 e.extra_compile_args = platform_copt[c] 142 152 143 153 build_ext.build_extensions(self) 154 144 155 145 156 class BuildSphinxCommand(Command): … … 154 165 155 166 def run(self): 167 ''' First builds the sasmodels documentation if the directory 168 is present. Then builds the sasview docs. 169 ''' 170 ### AJJ - Add code for building sasmodels docs here: 171 # check for doc path 172 SASMODELS_DOCPATH = os.path.abspath(os.path.join(os.getcwd(), '..', 'sasmodels', 'doc')) 173 print("========= check for sasmodels at", SASMODELS_DOCPATH, "============") 174 if os.path.exists(SASMODELS_DOCPATH): 175 if os.path.isdir(SASMODELS_DOCPATH): 176 # if available, build sasmodels docs 177 print("============= Building sasmodels model documentation ===============") 178 smdocbuild = subprocess.call(["make", "-C", SASMODELS_DOCPATH, "html"]) 179 else: 180 # if not available warning message 181 print("== !!WARNING!! sasmodels directory not found. Cannot build model docs. ==") 182 183 #Now build sasview (+sasmodels) docs 156 184 sys.path.append("docs/sphinx-docs") 157 185 import build_sphinx 158 186 build_sphinx.rebuild() 159 187 188 160 189 # sas module 161 190 package_dir["sas"] = os.path.join("src", "sas") … … 171 200 172 201 # sas.sascalc.invariant 173 package_dir["sas.sascalc.invariant"] = os.path.join("src", "sas", "sascalc", "invariant") 202 package_dir["sas.sascalc.invariant"] = os.path.join( 203 "src", "sas", "sascalc", "invariant") 174 204 packages.extend(["sas.sascalc.invariant"]) 175 205 … … 177 207 guiframe_path = os.path.join("src", "sas", "sasgui", "guiframe") 178 208 package_dir["sas.sasgui.guiframe"] = guiframe_path 179 package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join(os.path.join(guiframe_path, "local_perspectives")) 209 package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join( 210 os.path.join(guiframe_path, "local_perspectives")) 180 211 package_data["sas.sasgui.guiframe"] = ['images/*', 'media/*'] 181 packages.extend(["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 212 packages.extend( 213 ["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 182 214 # build local plugin 183 215 for d in os.listdir(os.path.join(guiframe_path, "local_perspectives")): 184 if d not in ['.svn', '__init__.py', '__init__.pyc']:216 if d not in ['.svn', '__init__.py', '__init__.pyc']: 185 217 package_name = "sas.sasgui.guiframe.local_perspectives." + d 186 218 packages.append(package_name) 187 package_dir[package_name] = os.path.join(guiframe_path, "local_perspectives", d) 219 package_dir[package_name] = os.path.join( 220 guiframe_path, "local_perspectives", d) 188 221 189 222 # sas.sascalc.dataloader 190 package_dir["sas.sascalc.dataloader"] = os.path.join("src", "sas", "sascalc", "dataloader") 191 package_data["sas.sascalc.dataloader.readers"] = ['defaults.json','schema/*.xsd'] 192 packages.extend(["sas.sascalc.dataloader","sas.sascalc.dataloader.readers","sas.sascalc.dataloader.readers.schema"]) 223 package_dir["sas.sascalc.dataloader"] = os.path.join( 224 "src", "sas", "sascalc", "dataloader") 225 package_data["sas.sascalc.dataloader.readers"] = [ 226 'defaults.json', 'schema/*.xsd'] 227 packages.extend(["sas.sascalc.dataloader", "sas.sascalc.dataloader.readers", 228 "sas.sascalc.dataloader.readers.schema"]) 229 193 230 194 231 # sas.sascalc.calculator 195 232 gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") 196 233 package_dir["sas.sascalc.calculator.core"] = gen_dir 197 package_dir["sas.sascalc.calculator"] = os.path.join( "src", "sas", "sascalc", "calculator")198 packages.extend(["sas.sascalc.calculator","sas.sascalc.calculator.core"])199 ext_modules.append( Extension("sas.sascalc.calculator.core.sld2i", 200 sources = [ 201 os.path.join(gen_dir, "sld2i_module.cpp"),202 os.path.join(gen_dir, "sld2i.cpp"),203 os.path.join(gen_dir, "libfunc.c"),204 os.path.join(gen_dir, "librefl.c"),205 ],206 include_dirs=[gen_dir],207 )208 )209 210 234 package_dir["sas.sascalc.calculator"] = os.path.join( 235 "src", "sas", "sascalc", "calculator") 236 packages.extend(["sas.sascalc.calculator", "sas.sascalc.calculator.core"]) 237 ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i", 238 sources=[ 239 os.path.join(gen_dir, "sld2i_module.cpp"), 240 os.path.join(gen_dir, "sld2i.cpp"), 241 os.path.join(gen_dir, "libfunc.c"), 242 os.path.join(gen_dir, "librefl.c"), 243 ], 244 include_dirs=[gen_dir], 245 ) 246 ) 247 211 248 # sas.sascalc.pr 212 srcdir 249 srcdir = os.path.join("src", "sas", "sascalc", "pr", "c_extensions") 213 250 package_dir["sas.sascalc.pr.core"] = srcdir 214 package_dir["sas.sascalc.pr"] = os.path.join("src","sas", "sascalc", "pr") 215 packages.extend(["sas.sascalc.pr","sas.sascalc.pr.core"]) 216 ext_modules.append( Extension("sas.sascalc.pr.core.pr_inversion", 217 sources = [os.path.join(srcdir, "Cinvertor.c"), 218 os.path.join(srcdir, "invertor.c"), 219 ], 220 include_dirs=[], 221 ) ) 222 251 package_dir["sas.sascalc.pr"] = os.path.join("src", "sas", "sascalc", "pr") 252 packages.extend(["sas.sascalc.pr", "sas.sascalc.pr.core"]) 253 ext_modules.append(Extension("sas.sascalc.pr.core.pr_inversion", 254 sources=[os.path.join(srcdir, "Cinvertor.c"), 255 os.path.join(srcdir, "invertor.c"), 256 ], 257 include_dirs=[], 258 )) 259 260 261 # sas.sascalc.file_converter 262 mydir = os.path.join("src", "sas", "sascalc", "file_converter", "c_ext") 263 package_dir["sas.sascalc.file_converter.core"] = mydir 264 package_dir["sas.sascalc.file_converter"] = os.path.join( 265 "src", "sas", "sascalc", "file_converter") 266 packages.extend(["sas.sascalc.file_converter", 267 "sas.sascalc.file_converter.core"]) 268 ext_modules.append(Extension("sas.sascalc.file_converter.core.bsl_loader", 269 sources=[os.path.join(mydir, "bsl_loader.c")], 270 include_dirs=[np.get_include()], 271 )) 272 273 # sas.sascalc.corfunc 274 package_dir["sas.sascalc.corfunc"] = os.path.join( 275 "src", "sas", "sascalc", "corfunc") 276 277 packages.extend(["sas.sascalc.corfunc"]) 278 223 279 # sas.sascalc.fit 224 280 package_dir["sas.sascalc.fit"] = os.path.join("src", "sas", "sascalc", "fit") … … 226 282 227 283 # Perspectives 228 package_dir["sas.sasgui.perspectives"] = os.path.join("src", "sas", "sasgui", "perspectives") 229 package_dir["sas.sasgui.perspectives.pr"] = os.path.join("src", "sas", "sasgui", "perspectives", "pr") 230 packages.extend(["sas.sasgui.perspectives","sas.sasgui.perspectives.pr"]) 231 package_data["sas.sasgui.perspectives.pr"] = ['images/*'] 232 233 package_dir["sas.sasgui.perspectives.invariant"] = os.path.join("src", "sas", "sasgui", "perspectives", "invariant") 284 package_dir["sas.sasgui.perspectives"] = os.path.join( 285 "src", "sas", "sasgui", "perspectives") 286 package_dir["sas.sasgui.perspectives.pr"] = os.path.join( 287 "src", "sas", "sasgui", "perspectives", "pr") 288 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.pr"]) 289 package_data["sas.sasgui.perspectives.pr"] = ['media/*'] 290 291 package_dir["sas.sasgui.perspectives.invariant"] = os.path.join( 292 "src", "sas", "sasgui", "perspectives", "invariant") 234 293 packages.extend(["sas.sasgui.perspectives.invariant"]) 235 package_data['sas.sasgui.perspectives.invariant'] = [os.path.join("media",'*')] 236 237 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting") 238 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 239 packages.extend(["sas.sasgui.perspectives.fitting", "sas.sasgui.perspectives.fitting.plugin_models"]) 240 package_data['sas.sasgui.perspectives.fitting'] = ['media/*', 'plugin_models/*'] 241 242 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.calculator"]) 294 package_data['sas.sasgui.perspectives.invariant'] = [ 295 os.path.join("media", '*')] 296 297 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join( 298 "src", "sas", "sasgui", "perspectives", "fitting") 299 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join( 300 "src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 301 packages.extend(["sas.sasgui.perspectives.fitting", 302 "sas.sasgui.perspectives.fitting.plugin_models"]) 303 package_data['sas.sasgui.perspectives.fitting'] = [ 304 'media/*', 'plugin_models/*'] 305 306 packages.extend(["sas.sasgui.perspectives", 307 "sas.sasgui.perspectives.calculator"]) 243 308 package_data['sas.sasgui.perspectives.calculator'] = ['images/*', 'media/*'] 244 309 310 package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join( 311 "src", "sas", "sasgui", "perspectives", "corfunc") 312 packages.extend(["sas.sasgui.perspectives.corfunc"]) 313 package_data['sas.sasgui.perspectives.corfunc'] = ['media/*'] 314 315 package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join( 316 "src", "sas", "sasgui", "perspectives", "file_converter") 317 packages.extend(["sas.sasgui.perspectives.file_converter"]) 318 package_data['sas.sasgui.perspectives.file_converter'] = ['media/*'] 319 245 320 # Data util 246 package_dir["sas.sascalc.data_util"] = os.path.join("src", "sas", "sascalc", "data_util") 321 package_dir["sas.sascalc.data_util"] = os.path.join( 322 "src", "sas", "sascalc", "data_util") 247 323 packages.append("sas.sascalc.data_util") 248 324 249 325 # Plottools 250 package_dir["sas.sasgui.plottools"] = os.path.join("src", "sas", "sasgui", "plottools") 326 package_dir["sas.sasgui.plottools"] = os.path.join( 327 "src", "sas", "sasgui", "plottools") 251 328 packages.append("sas.sasgui.plottools") 252 329 … … 256 333 257 334 EXTENSIONS = [".c", ".cpp"] 335 258 336 259 337 def append_file(file_list, dir_path): … … 275 353 file_list.append(os.path.join(sub_dir, new_f)) 276 354 355 277 356 # Comment out the following to avoid rebuilding all the models 278 357 file_sources = [] 279 358 append_file(file_sources, gen_dir) 280 359 281 # Wojtek's hacky way to add doc files while bundling egg282 # def add_doc_files(directory):360 # Wojtek's hacky way to add doc files while bundling egg 361 # def add_doc_files(directory): 283 362 # paths = [] 284 363 # for (path, directories, filenames) in os.walk(directory): … … 292 371 package_data['sas.sasview'] = ['images/*', 293 372 'media/*', 373 'logging.ini', 294 374 'test/*.txt', 295 375 'test/1d_data/*', 296 376 'test/2d_data/*', 377 'test/convertible_files/*', 378 'test/coordinate_data/*', 379 'test/image_data/*', 380 'test/media/*', 381 'test/other_files/*', 297 382 'test/save_states/*', 298 'test/ upcoming_formats/*',299 'default_categories.json']383 'test/sesans_data/*' 384 ] 300 385 packages.append("sas.sasview") 301 386 … … 304 389 305 390 # 'lxml>=2.2.2', 306 'lxml', 'h5py ==2.5',307 308 # #The following dependecies won't install automatically, so assume them309 # #The numbers should be bumped up for matplotlib and wxPython as well.391 'lxml', 'h5py', 392 393 # The following dependecies won't install automatically, so assume them 394 # The numbers should be bumped up for matplotlib and wxPython as well. 310 395 # 'numpy>=1.4.1', 'scipy>=0.7.2', 'matplotlib>=0.99.1.1', 311 396 # 'wxPython>=2.8.11', 'pil', 312 313 314 if os.name =='nt':397 ] 398 399 if os.name == 'nt': 315 400 required.extend(['html5lib', 'reportlab']) 316 401 else: … … 318 403 required.extend(['pillow']) 319 404 320 # Set up SasView 405 # Set up SasView 321 406 setup( 322 407 name="sasview", 323 version =VERSION,324 description ="SasView application",325 author ="SasView Team",326 author_email ="developers@sasview.org",327 url ="http://sasview.org",328 license ="PSF",329 keywords ="small-angle x-ray and neutron scattering analysis",330 download_url ="https://github.com/SasView/sasview.git",331 package_dir =package_dir,332 packages =packages,333 package_data =package_data,334 ext_modules =ext_modules,335 install_requires =required,336 zip_safe =False,337 entry_points ={338 'console_scripts': [ "sasview = sas.sasview.sasview:run_cli"]339 },340 cmdclass = {341 'build_ext': build_ext_subclass,342 'docs': BuildSphinxCommand,343 'disable_openmp': DisableOpenMPCommand,344 }345 ) 408 version=VERSION, 409 description="SasView application", 410 author="SasView Team", 411 author_email="developers@sasview.org", 412 url="http://sasview.org", 413 license="PSF", 414 keywords="small-angle x-ray and neutron scattering analysis", 415 download_url="https://github.com/SasView/sasview.git", 416 package_dir=package_dir, 417 packages=packages, 418 package_data=package_data, 419 ext_modules=ext_modules, 420 install_requires=required, 421 zip_safe=False, 422 entry_points={ 423 'console_scripts': [ 424 "sasview = sas.sasview.sasview:run", 425 ] 426 }, 427 cmdclass={'build_ext': build_ext_subclass, 428 'docs': BuildSphinxCommand, 429 'disable_openmp': DisableOpenMPCommand} 430 )
Note: See TracChangeset
for help on using the changeset viewer.