Changeset 6ca9d90 in sasview for setup.py


Ignore:
Timestamp:
Apr 11, 2017 8:08:59 AM (7 years ago)
Author:
GitHub <noreply@…>
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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
97c60f8, 9c23f40
Parents:
a42fb8e (diff), b854587 (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.
git-author:
Andrew Jackson <andrew.jackson@…> (04/11/17 08:08:59)
git-committer:
GitHub <noreply@…> (04/11/17 08:08:59)
Message:

Merge pull request #86 from SasView?/pytest

URGENT: Logging conf file working! This was breaking master.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r14bb7a4 rb854587  
     1# -*- coding: utf-8 -*- 
     2#!/usr/bin/env python 
     3 
    14""" 
    25    Setup for SasView 
    3     #TODO: Add checks to see that all the dependencies are on the system 
     6    TODO: Add checks to see that all the dependencies are on the system 
    47""" 
    5 import sys 
     8 
    69import os 
    710import subprocess 
    811import shutil 
    9 from setuptools import setup, Extension 
     12import sys 
    1013from distutils.command.build_ext import build_ext 
    1114from distutils.core import Command 
     15 
    1216import numpy as np 
     17from setuptools import Extension, setup 
    1318 
    1419# Manage version number ###################################### 
    1520import sasview 
     21 
    1622VERSION = sasview.__version__ 
    1723############################################################## 
     
    2632# except when there is no such file 
    2733# Todo : make this list generic 
    28 #plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 
     34# plugin_model_list = ['polynominal5.py', 'sph_bessel_jn.py', 
    2935#                      'sum_Ap1_1_Ap2.py', 'sum_p1_p2.py', 
    3036#                      'testmodel_2.py', 'testmodel.py', 
     
    3642SASVIEW_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build") 
    3743 
    38 sas_dir = os.path.join(os.path.expanduser("~"),'.sasview') 
     44sas_dir = os.path.join(os.path.expanduser("~"), '.sasview') 
    3945if os.path.isdir(sas_dir): 
    4046    f_path = os.path.join(sas_dir, "sasview.log") 
     
    4854        os.remove(f_path) 
    4955    #f_path = os.path.join(sas_dir, 'plugin_models') 
    50     #if os.path.isdir(f_path): 
     56    # if os.path.isdir(f_path): 
    5157    #     for f in os.listdir(f_path): 
    5258    #         if f in plugin_model_list: 
     
    5460    #             os.remove(file_path) 
    5561    if os.path.exists(SASVIEW_BUILD): 
    56         print("Removing existing build directory", SASVIEW_BUILD, "for a clean build") 
     62        print("Removing existing build directory", 
     63              SASVIEW_BUILD, "for a clean build") 
    5764        shutil.rmtree(SASVIEW_BUILD) 
    5865 
     
    6471enable_openmp = False 
    6572 
    66 if sys.platform =='darwin': 
     73if sys.platform == 'darwin': 
    6774    if not is_64bits: 
    6875        # Disable OpenMP 
     
    7885 
    7986# Options to enable OpenMP 
    80 copt =  {'msvc': ['/openmp'], 
    81          'mingw32' : ['-fopenmp'], 
    82          'unix' : ['-fopenmp']} 
    83 lopt =  {'msvc': ['/MANIFEST'], 
    84          'mingw32' : ['-fopenmp'], 
    85          'unix' : ['-lgomp']} 
     87copt = {'msvc': ['/openmp'], 
     88        'mingw32': ['-fopenmp'], 
     89        'unix': ['-fopenmp']} 
     90lopt = {'msvc': ['/MANIFEST'], 
     91        'mingw32': ['-fopenmp'], 
     92        'unix': ['-lgomp']} 
    8693 
    8794# Platform-specific link options 
    88 platform_lopt = {'msvc' : ['/MANIFEST']} 
     95platform_lopt = {'msvc': ['/MANIFEST']} 
    8996platform_copt = {} 
    9097 
    9198# Set copts to get compile working on OS X >= 10.9 using clang 
    92 if sys.platform =='darwin': 
     99if sys.platform == 'darwin': 
    93100    try: 
    94101        darwin_ver = int(os.uname()[2].split('.')[0]) 
    95102        if darwin_ver >= 13 and darwin_ver < 14: 
    96             platform_copt = {'unix' : ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 
     103            platform_copt = { 
     104                'unix': ['-Wno-error=unused-command-line-argument-hard-error-in-future']} 
    97105    except: 
    98106        print("PROBLEM determining Darwin version") 
     107 
    99108 
    100109class DisableOpenMPCommand(Command): 
     
    115124        pass 
    116125 
    117 class build_ext_subclass( build_ext ): 
     126 
     127class build_ext_subclass(build_ext): 
    118128    def build_extensions(self): 
    119129        # Get 64-bitness 
     
    125135            if c in copt: 
    126136                for e in self.extensions: 
    127                     e.extra_compile_args = copt[ c ] 
     137                    e.extra_compile_args = copt[c] 
    128138            if c in lopt: 
    129139                for e in self.extensions: 
    130                     e.extra_link_args = lopt[ c ] 
     140                    e.extra_link_args = lopt[c] 
    131141 
    132142        # Platform-specific build options 
    133143        if c in platform_lopt: 
    134144            for e in self.extensions: 
    135                 e.extra_link_args = platform_lopt[ c ] 
     145                e.extra_link_args = platform_lopt[c] 
    136146 
    137147        if c in platform_copt: 
    138148            for e in self.extensions: 
    139                 e.extra_compile_args = platform_copt[ c ] 
    140  
     149                e.extra_compile_args = platform_copt[c] 
    141150 
    142151        build_ext.build_extensions(self) 
     152 
    143153 
    144154class BuildSphinxCommand(Command): 
     
    174184        build_sphinx.rebuild() 
    175185 
     186 
    176187# sas module 
    177188package_dir["sas"] = os.path.join("src", "sas") 
     
    187198 
    188199# sas.sascalc.invariant 
    189 package_dir["sas.sascalc.invariant"] = os.path.join("src", "sas", "sascalc", "invariant") 
     200package_dir["sas.sascalc.invariant"] = os.path.join( 
     201    "src", "sas", "sascalc", "invariant") 
    190202packages.extend(["sas.sascalc.invariant"]) 
    191203 
     
    193205guiframe_path = os.path.join("src", "sas", "sasgui", "guiframe") 
    194206package_dir["sas.sasgui.guiframe"] = guiframe_path 
    195 package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join(os.path.join(guiframe_path, "local_perspectives")) 
     207package_dir["sas.sasgui.guiframe.local_perspectives"] = os.path.join( 
     208    os.path.join(guiframe_path, "local_perspectives")) 
    196209package_data["sas.sasgui.guiframe"] = ['images/*', 'media/*'] 
    197 packages.extend(["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 
     210packages.extend( 
     211    ["sas.sasgui.guiframe", "sas.sasgui.guiframe.local_perspectives"]) 
    198212# build local plugin 
    199213for d in os.listdir(os.path.join(guiframe_path, "local_perspectives")): 
     
    201215        package_name = "sas.sasgui.guiframe.local_perspectives." + d 
    202216        packages.append(package_name) 
    203         package_dir[package_name] = os.path.join(guiframe_path, "local_perspectives", d) 
     217        package_dir[package_name] = os.path.join( 
     218            guiframe_path, "local_perspectives", d) 
    204219 
    205220# sas.sascalc.dataloader 
    206 package_dir["sas.sascalc.dataloader"] = os.path.join("src", "sas", "sascalc", "dataloader") 
    207 package_data["sas.sascalc.dataloader.readers"] = ['defaults.json', 'schema/*.xsd'] 
    208 packages.extend(["sas.sascalc.dataloader", "sas.sascalc.dataloader.readers", "sas.sascalc.dataloader.readers.schema"]) 
     221package_dir["sas.sascalc.dataloader"] = os.path.join( 
     222    "src", "sas", "sascalc", "dataloader") 
     223package_data["sas.sascalc.dataloader.readers"] = [ 
     224    'defaults.json', 'schema/*.xsd'] 
     225packages.extend(["sas.sascalc.dataloader", "sas.sascalc.dataloader.readers", 
     226                 "sas.sascalc.dataloader.readers.schema"]) 
     227 
    209228 
    210229# sas.sascalc.calculator 
    211230gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions") 
    212231package_dir["sas.sascalc.calculator.core"] = gen_dir 
    213 package_dir["sas.sascalc.calculator"] = os.path.join("src", "sas", "sascalc", "calculator") 
    214 packages.extend(["sas.sascalc.calculator","sas.sascalc.calculator.core"]) 
    215 ext_modules.append( Extension("sas.sascalc.calculator.core.sld2i", 
    216         sources = [ 
    217             os.path.join(gen_dir, "sld2i_module.cpp"), 
    218             os.path.join(gen_dir, "sld2i.cpp"), 
    219             os.path.join(gen_dir, "libfunc.c"), 
    220             os.path.join(gen_dir, "librefl.c"), 
    221         ], 
    222         include_dirs=[gen_dir], 
    223     ) 
    224 ) 
     232package_dir["sas.sascalc.calculator"] = os.path.join( 
     233    "src", "sas", "sascalc", "calculator") 
     234packages.extend(["sas.sascalc.calculator", "sas.sascalc.calculator.core"]) 
     235ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i", 
     236                             sources=[ 
     237                                 os.path.join(gen_dir, "sld2i_module.cpp"), 
     238                                 os.path.join(gen_dir, "sld2i.cpp"), 
     239                                 os.path.join(gen_dir, "libfunc.c"), 
     240                                 os.path.join(gen_dir, "librefl.c"), 
     241                             ], 
     242                             include_dirs=[gen_dir], 
     243                             ) 
     244                   ) 
    225245 
    226246# sas.sascalc.pr 
    227 srcdir  = os.path.join("src", "sas", "sascalc", "pr", "c_extensions") 
     247srcdir = os.path.join("src", "sas", "sascalc", "pr", "c_extensions") 
    228248package_dir["sas.sascalc.pr.core"] = srcdir 
    229249package_dir["sas.sascalc.pr"] = os.path.join("src", "sas", "sascalc", "pr") 
    230 packages.extend(["sas.sascalc.pr","sas.sascalc.pr.core"]) 
    231 ext_modules.append( Extension("sas.sascalc.pr.core.pr_inversion", 
    232                               sources = [os.path.join(srcdir, "Cinvertor.c"), 
    233                                          os.path.join(srcdir, "invertor.c"), 
    234                                          ], 
    235                               include_dirs=[], 
    236                               ) ) 
     250packages.extend(["sas.sascalc.pr", "sas.sascalc.pr.core"]) 
     251ext_modules.append(Extension("sas.sascalc.pr.core.pr_inversion", 
     252                             sources=[os.path.join(srcdir, "Cinvertor.c"), 
     253                                      os.path.join(srcdir, "invertor.c"), 
     254                                      ], 
     255                             include_dirs=[], 
     256                             )) 
     257 
    237258 
    238259# sas.sascalc.file_converter 
    239260mydir = os.path.join("src", "sas", "sascalc", "file_converter", "c_ext") 
    240261package_dir["sas.sascalc.file_converter.core"] = mydir 
    241 package_dir["sas.sascalc.file_converter"] = os.path.join("src", "sas", "sascalc", "file_converter") 
    242 packages.extend(["sas.sascalc.file_converter", "sas.sascalc.file_converter.core"]) 
    243 ext_modules.append( Extension("sas.sascalc.file_converter.core.bsl_loader", 
    244                               sources = [os.path.join(mydir, "bsl_loader.c")], 
    245                               include_dirs=[np.get_include()], 
    246                               ) ) 
    247  
    248 #sas.sascalc.corfunc 
    249 package_dir["sas.sascalc.corfunc"] = os.path.join("src", "sas", "sascalc", "corfunc") 
     262package_dir["sas.sascalc.file_converter"] = os.path.join( 
     263    "src", "sas", "sascalc", "file_converter") 
     264packages.extend(["sas.sascalc.file_converter", 
     265                 "sas.sascalc.file_converter.core"]) 
     266ext_modules.append(Extension("sas.sascalc.file_converter.core.bsl_loader", 
     267                             sources=[os.path.join(mydir, "bsl_loader.c")], 
     268                             include_dirs=[np.get_include()], 
     269                             )) 
     270 
     271# sas.sascalc.corfunc 
     272package_dir["sas.sascalc.corfunc"] = os.path.join( 
     273    "src", "sas", "sascalc", "corfunc") 
     274 
    250275packages.extend(["sas.sascalc.corfunc"]) 
    251276 
     
    255280 
    256281# Perspectives 
    257 package_dir["sas.sasgui.perspectives"] = os.path.join("src", "sas", "sasgui", "perspectives") 
    258 package_dir["sas.sasgui.perspectives.pr"] = os.path.join("src", "sas", "sasgui", "perspectives", "pr") 
    259 packages.extend(["sas.sasgui.perspectives","sas.sasgui.perspectives.pr"]) 
     282package_dir["sas.sasgui.perspectives"] = os.path.join( 
     283    "src", "sas", "sasgui", "perspectives") 
     284package_dir["sas.sasgui.perspectives.pr"] = os.path.join( 
     285    "src", "sas", "sasgui", "perspectives", "pr") 
     286packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.pr"]) 
    260287package_data["sas.sasgui.perspectives.pr"] = ['media/*'] 
    261288 
    262 package_dir["sas.sasgui.perspectives.invariant"] = os.path.join("src", "sas", "sasgui", "perspectives", "invariant") 
     289package_dir["sas.sasgui.perspectives.invariant"] = os.path.join( 
     290    "src", "sas", "sasgui", "perspectives", "invariant") 
    263291packages.extend(["sas.sasgui.perspectives.invariant"]) 
    264 package_data['sas.sasgui.perspectives.invariant'] = [os.path.join("media",'*')] 
    265  
    266 package_dir["sas.sasgui.perspectives.fitting"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting") 
    267 package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join("src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 
    268 packages.extend(["sas.sasgui.perspectives.fitting", "sas.sasgui.perspectives.fitting.plugin_models"]) 
    269 package_data['sas.sasgui.perspectives.fitting'] = ['media/*', 'plugin_models/*'] 
    270  
    271 packages.extend(["sas.sasgui.perspectives", "sas.sasgui.perspectives.calculator"]) 
     292package_data['sas.sasgui.perspectives.invariant'] = [ 
     293    os.path.join("media", '*')] 
     294 
     295package_dir["sas.sasgui.perspectives.fitting"] = os.path.join( 
     296    "src", "sas", "sasgui", "perspectives", "fitting") 
     297package_dir["sas.sasgui.perspectives.fitting.plugin_models"] = os.path.join( 
     298    "src", "sas", "sasgui", "perspectives", "fitting", "plugin_models") 
     299packages.extend(["sas.sasgui.perspectives.fitting", 
     300                 "sas.sasgui.perspectives.fitting.plugin_models"]) 
     301package_data['sas.sasgui.perspectives.fitting'] = [ 
     302    'media/*', 'plugin_models/*'] 
     303 
     304packages.extend(["sas.sasgui.perspectives", 
     305                 "sas.sasgui.perspectives.calculator"]) 
    272306package_data['sas.sasgui.perspectives.calculator'] = ['images/*', 'media/*'] 
    273307 
    274 package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join("src", "sas", "sasgui", "perspectives", "corfunc") 
     308package_dir["sas.sasgui.perspectives.corfunc"] = os.path.join( 
     309    "src", "sas", "sasgui", "perspectives", "corfunc") 
    275310packages.extend(["sas.sasgui.perspectives.corfunc"]) 
    276311package_data['sas.sasgui.perspectives.corfunc'] = ['media/*'] 
    277312 
    278 package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join("src", "sas", "sasgui", "perspectives", "file_converter") 
     313package_dir["sas.sasgui.perspectives.file_converter"] = os.path.join( 
     314    "src", "sas", "sasgui", "perspectives", "file_converter") 
    279315packages.extend(["sas.sasgui.perspectives.file_converter"]) 
    280316package_data['sas.sasgui.perspectives.file_converter'] = ['media/*'] 
    281317 
    282318# Data util 
    283 package_dir["sas.sascalc.data_util"] = os.path.join("src", "sas", "sascalc", "data_util") 
     319package_dir["sas.sascalc.data_util"] = os.path.join( 
     320    "src", "sas", "sascalc", "data_util") 
    284321packages.append("sas.sascalc.data_util") 
    285322 
    286323# Plottools 
    287 package_dir["sas.sasgui.plottools"] = os.path.join("src", "sas", "sasgui", "plottools") 
     324package_dir["sas.sasgui.plottools"] = os.path.join( 
     325    "src", "sas", "sasgui", "plottools") 
    288326packages.append("sas.sasgui.plottools") 
    289327 
     
    293331 
    294332EXTENSIONS = [".c", ".cpp"] 
     333 
    295334 
    296335def append_file(file_list, dir_path): 
     
    312351                        file_list.append(os.path.join(sub_dir, new_f)) 
    313352 
     353 
    314354# Comment out the following to avoid rebuilding all the models 
    315355file_sources = [] 
    316356append_file(file_sources, gen_dir) 
    317357 
    318 #Wojtek's hacky way to add doc files while bundling egg 
    319 #def add_doc_files(directory): 
     358# Wojtek's hacky way to add doc files while bundling egg 
     359# def add_doc_files(directory): 
    320360#    paths = [] 
    321361#    for (path, directories, filenames) in os.walk(directory): 
     
    330370package_data['sas.sasview'] = ['images/*', 
    331371                               'media/*', 
     372                               'logging.ini', 
    332373                               'test/*.txt', 
    333374                               'test/1d_data/*', 
     
    349390    'lxml', 'h5py', 
    350391 
    351     ## The following dependecies won't install automatically, so assume them 
    352     ## The numbers should be bumped up for matplotlib and wxPython as well. 
     392    # The following dependecies won't install automatically, so assume them 
     393    # The numbers should be bumped up for matplotlib and wxPython as well. 
    353394    # 'numpy>=1.4.1', 'scipy>=0.7.2', 'matplotlib>=0.99.1.1', 
    354395    # 'wxPython>=2.8.11', 'pil', 
    355     ] 
    356  
    357 if os.name=='nt': 
     396] 
     397 
     398if os.name == 'nt': 
    358399    required.extend(['html5lib', 'reportlab']) 
    359400else: 
     
    364405setup( 
    365406    name="sasview", 
    366     version = VERSION, 
    367     description = "SasView application", 
    368     author = "SasView Team", 
    369     author_email = "developers@sasview.org", 
    370     url = "http://sasview.org", 
    371     license = "PSF", 
    372     keywords = "small-angle x-ray and neutron scattering analysis", 
    373     download_url = "https://github.com/SasView/sasview.git", 
    374     package_dir = package_dir, 
    375     packages = packages, 
    376     package_data = package_data, 
    377     ext_modules = ext_modules, 
    378     install_requires = required, 
    379     zip_safe = False, 
    380     entry_points = { 
    381                     'console_scripts':[ 
    382                                        "sasview = sas.sasview.sasview:run", 
    383                                        ] 
    384                     }, 
    385     cmdclass = {'build_ext': build_ext_subclass, 
    386                 'docs': BuildSphinxCommand, 
    387                 'disable_openmp': DisableOpenMPCommand} 
    388     ) 
     407    version=VERSION, 
     408    description="SasView application", 
     409    author="SasView Team", 
     410    author_email="developers@sasview.org", 
     411    url="http://sasview.org", 
     412    license="PSF", 
     413    keywords="small-angle x-ray and neutron scattering analysis", 
     414    download_url="https://github.com/SasView/sasview.git", 
     415    package_dir=package_dir, 
     416    packages=packages, 
     417    package_data=package_data, 
     418    ext_modules=ext_modules, 
     419    install_requires=required, 
     420    zip_safe=False, 
     421    entry_points={ 
     422        'console_scripts': [ 
     423            "sasview = sas.sasview.sasview:run", 
     424        ] 
     425    }, 
     426    cmdclass={'build_ext': build_ext_subclass, 
     427              'docs': BuildSphinxCommand, 
     428              'disable_openmp': DisableOpenMPCommand} 
     429) 
Note: See TracChangeset for help on using the changeset viewer.