|
1 | 1 | # http://www.scons.org/doc/production/HTML/scons-user.html |
2 | 2 | # This is: Sconstruct |
3 | 3 |
|
4 | | -import os, glob, copy, shutil, subprocess, imp, re |
| 4 | +import sys, os, glob, copy, shutil, subprocess, imp, re |
5 | 5 |
|
6 | 6 | from os.path import join |
7 | 7 |
|
@@ -575,13 +575,24 @@ if 'configure' in COMMAND_LINE_TARGETS: |
575 | 575 | def check_module(module_name): |
576 | 576 | print "Checking for Python module '" + module_name + "'... ", |
577 | 577 | try: |
578 | | - imp.find_module(module_name) |
579 | | - res = 1 |
580 | | - print "yes" |
581 | | - except: |
582 | | - res = 0 |
583 | | - print "no" |
584 | | - return res |
| 578 | + res = imp.find_module(module_name) |
| 579 | + if res: |
| 580 | + print "yes" |
| 581 | + return 1 |
| 582 | + except ImportError: |
| 583 | + pass |
| 584 | + for item in sys.path: |
| 585 | + importer = sys.path_importer_cache.get(item) |
| 586 | + if importer: |
| 587 | + try: |
| 588 | + result = importer.find_module(module_name, [item]) |
| 589 | + if result: |
| 590 | + print "yes" |
| 591 | + return 1 |
| 592 | + except ImportError: |
| 593 | + pass |
| 594 | + print "no" |
| 595 | + return 0 |
585 | 596 |
|
586 | 597 | conf = Configure( |
587 | 598 | env.Clone(LIBPATH=install_lib_paths, |
@@ -619,12 +630,12 @@ if 'configure' in COMMAND_LINE_TARGETS: |
619 | 630 | if not check_module(module_name): |
620 | 631 | if_failed("Python module '" + module_name + "' is not installed") |
621 | 632 | if not check_module('pbs'): |
622 | | - if_failed(""" |
623 | | - Python module '%s' is not installed |
| 633 | + print """ |
| 634 | + Python module 'pbs' is not installed |
624 | 635 | This module is only necessary for setting up and submitting DFT jobs |
625 | 636 | **It is not the module available from pip**" |
626 | 637 | It is available from: https://github.com/prisms-center/pbs |
627 | | - """ % module_name) |
| 638 | + """ |
628 | 639 |
|
629 | 640 |
|
630 | 641 | print "Configuration checks passed." |
|
0 commit comments