Commit 159605845d58fa1a2cced26713d1bf24bbb0f87e

Authored by Jürgen Knödlseder
1 parent afb51ddb

Add cscripts Python module test

cscripts/__init__.py.in
... ... @@ -88,4 +88,4 @@ def test():
88 88 test_python_cscripts.test(installed=True)
89 89  
90 90 # Add version
91   -__version__ = '@PACKAGE_VERSION@'
92 91 \ No newline at end of file
  92 +__version__ = '@PACKAGE_VERSION@'
... ...
cscripts/csinfo.py
... ... @@ -141,6 +141,7 @@ def csinfo_setup_check():
141 141 ctools_environ = False
142 142 gammalib_python = False
143 143 ctools_python = False
  144 + cscripts_python = False
144 145  
145 146 # Print header
146 147 print('\nGammalib / ctools setup check:\n')
... ... @@ -185,6 +186,16 @@ def csinfo_setup_check():
185 186 all_ok = False
186 187 ctools_python = True
187 188  
  189 + # Check if cscripts Python module import works
  190 + log(' cscripts Python import .......... ', end='')
  191 + try:
  192 + import cscripts
  193 + print('ok')
  194 + except:
  195 + print('NOT OK')
  196 + all_ok = False
  197 + cscripts_python = True
  198 +
188 199 # Signal if everything is okay, or notify about the problems that have
189 200 # been encountered
190 201 if all_ok:
... ... @@ -195,7 +206,7 @@ def csinfo_setup_check():
195 206 print(' - Have you set the GAMMALIB environment variable?')
196 207 if ctools_environ:
197 208 print(' - Have you set the CTOOLS environment variable?')
198   - if gammalib_python or ctools_python:
  209 + if gammalib_python or ctools_python or cscripts_python:
199 210 print(' - Did you source gammalib-init.sh?')
200 211 print(' - Did you source ctools-init.sh ?')
201 212 print(' - Are you using the correct Python ?')
... ... @@ -233,6 +244,15 @@ def csinfo_setup_info():
233 244 ctools_path = 'Not found'
234 245 ctools_version = 'Unknown'
235 246  
  247 + # Try importing cscripts, and flag if this was unsuccessful
  248 + try:
  249 + import cscripts
  250 + cscripts_path = cscripts.__path__[0]
  251 + cscripts_version = cscripts.__version__
  252 + except ImportError:
  253 + cscripts_path = 'Not found'
  254 + cscripts_version = 'Unknown'
  255 +
236 256 # Get GAMMALIB and CTOOLS environment variables
237 257 gammalib_env = os.environ.get('GAMMALIB', 'Not found')
238 258 ctools_env = os.environ.get('CTOOLS', 'Not found')
... ... @@ -241,13 +261,15 @@ def csinfo_setup_info():
241 261 print('\nGammalib / ctools setup info:\n')
242 262  
243 263 # Print package versions
244   - print(' Gammalib version ................. {0}'.format(gammalib_version))
245   - print(' ctools version ................. {0}'.format(ctools_version))
  264 + print(' Gammalib version ................ {0}'.format(gammalib_version))
  265 + print(' ctools version ................ {0}'.format(ctools_version))
  266 + print(' cscripts version ................ {0}'.format(cscripts_version))
246 267 print(' $GAMMALIB environment variable ... {0}'.format(gammalib_env))
247 268 print(' $CTOOLS environment variable ... {0}'.format(ctools_env))
248 269 print(' Python executable ................ {0}'.format(sys.executable))
249   - print(' gammalib Python package ......... {0}'.format(gammalib_path))
250   - print(' ctools Python package ........ {0}'.format(ctools_path))
  270 + print(' gammalib Python module .......... {0}'.format(gammalib_path))
  271 + print(' ctools Python module .......... {0}'.format(ctools_path))
  272 + print(' cscripts Python module .......... {0}'.format(cscripts_path))
251 273 print(' GAMMALIB CFLAGS ................. {0}'.format(get_pkg_config_info('cflags', 'gammalib')))
252 274 print(' CTOOLS CFLAGS ................. {0}'.format(get_pkg_config_info('cflags', 'ctools')))
253 275 print(' GAMMALIB LIBS ................. {0}'.format(get_pkg_config_info('libs', 'gammalib')))
... ...