@@ -694,32 +694,48 @@ def process_python_modules(ctx, modules):
694694 processed_modules .extend (modules )
695695
696696 if len (modules ) == 0 :
697- return modules
697+ return processed_modules
698698
699699 # temp file for pip report
700700 fd , path = tempfile .mkstemp ()
701701 os .close (fd )
702702
703703 # setup hostpython recipe
704- host_recipe = Recipe .get_recipe ("hostpython3" , ctx )
705-
706704 env = environ .copy ()
707- _python_path = host_recipe .get_path_to_python ()
708- libdir = glob .glob (join (_python_path , "build" , "lib*" ))
709- env ['PYTHONPATH' ] = host_recipe .site_dir + ":" + join (
710- _python_path , "Modules" ) + ":" + (libdir [0 ] if libdir else "" )
711-
712- shprint (
713- host_recipe .pip , 'install' , * modules ,
714- '--dry-run' , '--break-system-packages' , '--ignore-installed' ,
715- '--report' , path , '-q' , _env = env
716- )
705+ try :
706+ host_recipe = Recipe .get_recipe ("hostpython3" , ctx )
707+ _python_path = host_recipe .get_path_to_python ()
708+ libdir = glob .glob (join (_python_path , "build" , "lib*" ))
709+ env ['PYTHONPATH' ] = host_recipe .site_dir + ":" + join (
710+ _python_path , "Modules" ) + ":" + (libdir [0 ] if libdir else "" )
711+ pip = host_recipe .pip
712+ except Exception :
713+ # hostpython3 non available so we use system pip (like in tests)
714+ pip = sh .Command ("pip" )
715+
716+ try :
717+ shprint (
718+ pip , 'install' , * modules ,
719+ '--dry-run' , '--break-system-packages' , '--ignore-installed' ,
720+ '--report' , path , '-q' , _env = env
721+ )
722+ except Exception as e :
723+ warning (f"Auto module resolution failed: { e } " )
724+ return processed_modules
717725
718726 with open (path , "r" ) as f :
719- report = json .load (f )
727+ try :
728+ report = json .load (f )
729+ except Exception :
730+ report = {}
720731
721732 os .remove (path )
722733
734+ if "install" not in report .keys ():
735+ # pip changed json reporting format?
736+ warning ("Auto module resolution failed: invalid json!" )
737+ return processed_modules
738+
723739 info ('Extra resolved pure python dependencies :' )
724740
725741 ignored_str = " (ignored)"
@@ -740,7 +756,7 @@ def process_python_modules(ctx, modules):
740756 pure_python = False
741757
742758 # does this module matches any recipe name?
743- if mname .lower () in _requirement_names :
759+ if mname .lower (). replace ( "-" , "_" ) in _requirement_names :
744760 continue
745761
746762 color = Out_Fore .GREEN if pure_python else Out_Fore .RED
@@ -777,9 +793,7 @@ def run_pymodules_install(ctx, arch, modules, project_dir=None,
777793
778794 info ('*** PYTHON PACKAGE / PROJECT INSTALL STAGE FOR ARCH: {} ***' .format (arch ))
779795
780- # don't run process_python_modules in tests
781- if ctx .recipe_build_order .__class__ .__name__ != "Mock" :
782- modules = process_python_modules (ctx , modules )
796+ modules = process_python_modules (ctx , modules )
783797
784798 modules = [m for m in modules if ctx .not_has_package (m , arch )]
785799
0 commit comments