@@ -432,13 +432,7 @@ def finalize_options(self):
432432 if self .package_list :
433433 self .package_list = parse_package_list (self .package_list )
434434
435- def run (self ):
436- if len (self .sconscripts ) < 1 :
437- # nothing to do, just leave it here.
438- return
439-
440- check_numscons (minver = (0 , 11 , 0 ))
441-
435+ def _call_scons (self , scons_exec , sconscript , pkg_name , bootstrapping ):
442436 # XXX: when a scons script is missing, scons only prints warnings, and
443437 # does not return a failure (status is 0). We have to detect this from
444438 # distutils (this cannot work for recursive scons builds...)
@@ -447,8 +441,73 @@ def run(self):
447441 # there is a size limitation ? What is the standard solution in thise
448442 # case ?
449443
450- scons_exec = get_python_exec_invoc ()
451- scons_exec += ' ' + protect_path (pjoin (get_scons_local_path (), 'scons.py' ))
444+ cmd = [scons_exec , "-f" , sconscript , '-I.' ]
445+ if self .jobs :
446+ cmd .append (" --jobs=%d" % int (self .jobs ))
447+ if self .inplace :
448+ cmd .append ("inplace=1" )
449+ cmd .append ('scons_tool_path="%s"' % self .scons_tool_path )
450+ cmd .append ('src_dir="%s"' % pdirname (sconscript ))
451+ cmd .append ('pkg_name="%s"' % pkg_name )
452+ cmd .append ('log_level=%s' % self .log_level )
453+ #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib,
454+ # pdirname(sconscript))))
455+ cmd .append ('distutils_libdir=%s' %
456+ protect_path (get_distutils_libdir (self , pkg_name )))
457+ cmd .append ('distutils_clibdir=%s' %
458+ protect_path (get_distutils_clibdir (self , pkg_name )))
459+ prefix = get_distutils_install_prefix (pkg_name , self .inplace )
460+ cmd .append ('distutils_install_prefix=%s' % protect_path (prefix ))
461+
462+ if not self ._bypass_distutils_cc :
463+ cmd .append ('cc_opt=%s' % self .scons_compiler )
464+ if self .scons_compiler_path :
465+ cmd .append ('cc_opt_path=%s' % self .scons_compiler_path )
466+ else :
467+ cmd .append ('cc_opt=%s' % self .scons_compiler )
468+
469+ if self .scons_fcompiler :
470+ cmd .append ('f77_opt=%s' % self .scons_fcompiler )
471+ if self .scons_fcompiler_path :
472+ cmd .append ('f77_opt_path=%s' % self .scons_fcompiler_path )
473+
474+ if self .scons_cxxcompiler :
475+ cmd .append ('cxx_opt=%s' % self .scons_cxxcompiler )
476+ if self .scons_cxxcompiler_path :
477+ cmd .append ('cxx_opt_path=%s' % self .scons_cxxcompiler_path )
478+
479+ cmd .append ('include_bootstrap=%s' % dirl_to_str (get_numpy_include_dirs (sconscript )))
480+ cmd .append ('bypass=%s' % self .bypass )
481+ if self .silent :
482+ if int (self .silent ) == 2 :
483+ cmd .append ('-Q' )
484+ elif int (self .silent ) == 3 :
485+ cmd .append ('-s' )
486+ cmd .append ('silent=%d' % int (self .silent ))
487+ cmd .append ('bootstrapping=%d' % bootstrapping )
488+ cmdstr = ' ' .join (cmd )
489+ if int (self .silent ) < 1 :
490+ log .info ("Executing scons command (pkg is %s): %s " , pkg_name , cmdstr )
491+ else :
492+ log .info ("======== Executing scons command for pkg %s =========" , pkg_name )
493+ st = os .system (cmdstr )
494+ if st :
495+ #print "status is %d" % st
496+ msg = "Error while executing scons command."
497+ msg += " See above for more information.\n "
498+ msg += """\
499+ If you think it is a problem in numscons, you can also try executing the scons
500+ command with --log-level option for more detailed output of what numscons is
501+ doing, for example --log-level=0; the lowest the level is, the more detailed
502+ the output it."""
503+ raise DistutilsExecError (msg )
504+
505+ def run (self ):
506+ if len (self .sconscripts ) < 1 :
507+ # nothing to do, just leave it here.
508+ return
509+
510+ check_numscons (minver = (0 , 11 , 0 ))
452511
453512 if self .package_list is not None :
454513 id = select_packages (self .pkg_names , self .package_list )
@@ -463,9 +522,12 @@ def run(self):
463522 pkg_names = self .pkg_names
464523
465524 if is_bootstrapping ():
466- bootstrap = 1
525+ bootstrapping = 1
467526 else :
468- bootstrap = 0
527+ bootstrapping = 0
528+
529+ scons_exec = get_python_exec_invoc ()
530+ scons_exec += ' ' + protect_path (pjoin (get_scons_local_path (), 'scons.py' ))
469531
470532 for sconscript , pre_hook , post_hook , pkg_name in zip (sconscripts ,
471533 pre_hooks , post_hooks ,
@@ -474,66 +536,8 @@ def run(self):
474536 pre_hook ()
475537
476538 if sconscript :
477- cmd = [scons_exec , "-f" , sconscript , '-I.' ]
478- if self .jobs :
479- cmd .append (" --jobs=%d" % int (self .jobs ))
480- if self .inplace :
481- cmd .append ("inplace=1" )
482- cmd .append ('scons_tool_path="%s"' % self .scons_tool_path )
483- cmd .append ('src_dir="%s"' % pdirname (sconscript ))
484- cmd .append ('pkg_name="%s"' % pkg_name )
485- cmd .append ('log_level=%s' % self .log_level )
486- #cmd.append('distutils_libdir=%s' % protect_path(pjoin(self.build_lib,
487- # pdirname(sconscript))))
488- cmd .append ('distutils_libdir=%s' %
489- protect_path (get_distutils_libdir (self , pkg_name )))
490- cmd .append ('distutils_clibdir=%s' %
491- protect_path (get_distutils_clibdir (self , pkg_name )))
492- prefix = get_distutils_install_prefix (pkg_name , self .inplace )
493- cmd .append ('distutils_install_prefix=%s' % protect_path (prefix ))
494-
495- if not self ._bypass_distutils_cc :
496- cmd .append ('cc_opt=%s' % self .scons_compiler )
497- if self .scons_compiler_path :
498- cmd .append ('cc_opt_path=%s' % self .scons_compiler_path )
499- else :
500- cmd .append ('cc_opt=%s' % self .scons_compiler )
501-
502- if self .scons_fcompiler :
503- cmd .append ('f77_opt=%s' % self .scons_fcompiler )
504- if self .scons_fcompiler_path :
505- cmd .append ('f77_opt_path=%s' % self .scons_fcompiler_path )
506-
507- if self .scons_cxxcompiler :
508- cmd .append ('cxx_opt=%s' % self .scons_cxxcompiler )
509- if self .scons_cxxcompiler_path :
510- cmd .append ('cxx_opt_path=%s' % self .scons_cxxcompiler_path )
511-
512- cmd .append ('include_bootstrap=%s' % dirl_to_str (get_numpy_include_dirs (sconscript )))
513- cmd .append ('bypass=%s' % self .bypass )
514- if self .silent :
515- if int (self .silent ) == 2 :
516- cmd .append ('-Q' )
517- elif int (self .silent ) == 3 :
518- cmd .append ('-s' )
519- cmd .append ('silent=%d' % int (self .silent ))
520- cmd .append ('bootstrapping=%d' % bootstrap )
521- cmdstr = ' ' .join (cmd )
522- if int (self .silent ) < 1 :
523- log .info ("Executing scons command (pkg is %s): %s " , pkg_name , cmdstr )
524- else :
525- log .info ("======== Executing scons command for pkg %s =========" , pkg_name )
526- st = os .system (cmdstr )
527- if st :
528- #print "status is %d" % st
529- msg = "Error while executing scons command."
530- msg += " See above for more information.\n "
531- msg += """\
532- If you think it is a problem in numscons, you can also try executing the scons
533- command with --log-level option for more detailed output of what numscons is
534- doing, for example --log-level=0; the lowest the level is, the more detailed
535- the output it."""
536- raise DistutilsExecError (msg )
539+ self ._call_scons (scons_exec , sconscript , pkg_name , bootstrapping )
540+
537541 if post_hook :
538542 post_hook (** {'pkg_name' : pkg_name , 'scons_cmd' : self })
539543
0 commit comments