diff --git a/moose-core/.travis/travis_build_linux.sh b/moose-core/.travis/travis_build_linux.sh index ff3cdf0987389f4c7ac73b263219cc4c16b99550..49b7aa6ae5014ed1a53ad62c2edee002ba1a331c 100755 --- a/moose-core/.travis/travis_build_linux.sh +++ b/moose-core/.travis/travis_build_linux.sh @@ -1,4 +1,4 @@ -#!/bin/bash - +#!/usr/bin/env bash #=============================================================================== # # FILE: travis_build_linux.sh @@ -22,7 +22,7 @@ set -e PYTHON2="/usr/bin/python2" PYTHON3="/usr/bin/python3" -#MAKEFLAGS="-j 4" +#MAKEFLAGS="-j4" # Bug: `which python` returns /opt/bin/python* etc on travis. For which numpy # many not be available. Therefore, it is neccessary to use fixed path for @@ -32,6 +32,7 @@ PYTHON3="/usr/bin/python3" # Old makefile based flow. $PYTHON2 -m compileall -q . if type $PYTHON3 > /dev/null; then $PYTHON3 -m compileall -q . ; fi + ## CMAKE based flow mkdir -p _GSL_BUILD && cd _GSL_BUILD && \ cmake -DDEBUG=ON -DPYTHON_EXECUTABLE="$PYTHON2" .. diff --git a/moose-core/CMakeLists.txt b/moose-core/CMakeLists.txt index aa1c243d0ffd727d1926ec67bd07d9d31a38a087..128743396ace18dd14648f837608d71b97991035 100644 --- a/moose-core/CMakeLists.txt +++ b/moose-core/CMakeLists.txt @@ -1,5 +1,6 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) -cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +project(MOOSE) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -9,7 +10,6 @@ if(COMMAND cmake_policy) endif(POLICY CMP0050) endif(COMMAND cmake_policy) -project(MOOSE) include(CheckCXXCompiler.cmake) include(CheckIncludeFileCXX) @@ -48,8 +48,6 @@ message( STATUS "MOOSE Version ${MOOSE_VERSION}" ) # sure that we don't have any stray generated files lying around in the tree # (which would end up getting picked up by header search, instead of the correct # versions). - -message(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}") if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) message(FATAL_ERROR "======================================================================\n" @@ -415,17 +413,26 @@ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/moose DESTINATION bin ) -# This target is built by pymoose/CMakeLists.txt file. +# INSTALL python module. +# This target is built by pymoose/CMakeLists.txt file. Using the --prefix option +# always override debian default installation directory. It will be installed in +# site-packages instead of dist-packages. +# See https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570 +# HACK: Some trickery is involved. Don't pass --prefix if CMAKE_INSTALL_PREFIX is +# just /usr. This fixes debian builds. if(WITH_PYTHON) + if( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" ) + set(EXTRA_ARGS "" ) + else() + set(EXTRA_ARGS "--prefix ${CMAKE_INSTALL_PREFIX}") + endif( ) + install(CODE - " - execute_process( - COMMAND ${PYTHON_EXECUTABLE} setup.py install --prefix=${CMAKE_INSTALL_PREFIX} + "execute_process( + COMMAND ${PYTHON_EXECUTABLE} setup.py install ${EXTRA_ARGS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python + )" ) - " - ) - endif(WITH_PYTHON) # Print message to start build process diff --git a/moose-core/python/moose/genesis/writeKkit.py b/moose-core/python/moose/genesis/writeKkit.py index ba71603148d5e5096a41e14499027a7a11b442c2..4f2ea99a5b674235f2b7bf715c339e8b7e186435 100644 --- a/moose-core/python/moose/genesis/writeKkit.py +++ b/moose-core/python/moose/genesis/writeKkit.py @@ -14,6 +14,7 @@ import random import re import matplotlib import moose + from moose.chemUtil.chemConnectUtil import * from moose.chemUtil.graphUtils import * @@ -624,6 +625,6 @@ if __name__ == "__main__": output = modelpath+"_.g" written = write('/'+modelpath,output) if written: - print((" file written to ",output)) + print(" file written to ",output) else: print(" could be written to kkit format") diff --git a/moose-core/python/moose/moose.py b/moose-core/python/moose/moose.py index 99babb8ac0dc7612be6166e5119a19bdc87d232d..9257a5cde162273a945af677b9c9f2eef88ab6c9 100644 --- a/moose-core/python/moose/moose.py +++ b/moose-core/python/moose/moose.py @@ -12,9 +12,15 @@ from io import StringIO import moose.SBML.readSBML as _readSBML import moose.SBML.writeSBML as _writeSBML -import moose.genesis.writeKkit as _writeKkit import moose.chemUtil as _chemUtil +kkitImport_, kkitImport_error_ = True, '' +try: + import moose.genesis.writeKkit as _writeKkit +except ImportError as e: + kkitImport_ = False + kkitImport_err_ = '%s' % e + # Import function from C++ module into moose namespace. from moose._moose import * @@ -88,6 +94,11 @@ def mooseWriteKkit(modelpath, filepath,sceneitems={}): modelpath -- model path in moose \n filepath -- Path of output file. """ + global kkitImport_, kkitImport_err_ + if not kkitImport_: + print( '[WARN] Could not import module to enable this function' ) + print( '\tError was %s' % kkitImport_error_ ) + return False return _writeKkit.mooseWriteKkit(modelpath, filepath,sceneitems) diff --git a/moose-core/python/moose/moose_test.py b/moose-core/python/moose/moose_test.py index c6ff029f2c29643f2a24db529c283ebcab42db8d..e5f908bcfd8e05191510946f056bfc53dbda11ee 100644 --- a/moose-core/python/moose/moose_test.py +++ b/moose-core/python/moose/moose_test.py @@ -110,37 +110,45 @@ def suitable_for_testing( script ): return False, 'waits for user input' return True, 'OK' -def run_test( index, testfile ): +def run_test( index, testfile, timeout, **kwargs): """Run a given test """ global test_status_ global total_ pyExec = os.environ.get( 'PYTHON_EXECUTABLE', '/usr/bin/python' ) cmd = Command( [ pyExec, testfile ] ) + ti = time.time( ) - status = cmd.run( timeout = 60 ) name = os.path.basename( testfile ) + out = (name + '.' * 50)[:40] + print( '[TEST %3d/%d] %41s ' % (index, total_, out), end='' ) + sys.stdout.flush( ) + + # Run the test. + status = cmd.run( timeout = timeout ) t = time.time( ) - ti + print( '% 7.2f ' % t, end='' ) + sys.stdout.flush( ) + + # Change to directory and copy before running then test. cwd = os.path.dirname( testfile ) os.chdir( cwd ) with open( os.path.join( cwd, 'matplotlibrc' ), 'w' ) as f: _logger.debug( 'Writing matplotlibrc to %s' % cwd ) f.write( matplotlibrc_ ) - out = (name + '.' * 50)[:50] - print( '[TEST %3d/%d] %50s %.2f sec ' % (index, total_, out, t), end='' ) - sys.stdout.flush( ) if status != 0: if status == -15: - msg = '%2d TIMEOUT' % status + msg = '% 4d TIMEOUT' % status test_status_[ 'TIMED-OUT' ].append( testfile ) else: - msg = '%2d FAILED' % status + msg = '% 4d FAILED' % status test_status_[ 'FAILED' ].append( testfile ) print( msg ) else: - print( '%2d PASSED' % status ) + print( '% 4d PASSED' % status ) test_status_[ 'PASSED' ].append( testfile ) + sys.stdout.flush( ) def print_test_stat( ): @@ -148,7 +156,7 @@ def print_test_stat( ): for status in test_status_: print( 'Total %d tests %s' % (len( test_status_[status] ), status ) ) -def test_all( ): +def test_all( timeout, **kwargs ): global test_dir_ global total_ scripts = [ ] @@ -171,20 +179,21 @@ def test_all( ): total_ = len( scripts ) for i, s in enumerate( scripts ): _logger.info( 'Running test : %s' % s ) - run_test(i, s ) + run_test(i, s, timeout, **kwargs ) -def test( ): +def test( timeout = 60, **kwargs ): """Download and run tests. """ + print( '[INFO] Running test with timeout %d sec' % timeout ) try: init_test_dir( ) except Exception as e: print( '[INFO] Failed to clone moose-examples. Error was %s' % e ) quit( ) - test_all( ) + test_all( timeout = timeout, **kwargs ) print_test_stat( ) if __name__ == '__main__':