@@ -47,25 +47,33 @@ def node_gyp_rebuild(test_dir):
4747 print ('Building addon in' , test_dir )
4848 try :
4949 process = subprocess .Popen ([
50- node_bin ,
51- node_gyp ,
52- 'rebuild' ,
53- '--directory' , test_dir ,
54- '--nodedir' , headers_dir ,
55- '--python' , sys .executable ,
56- '--loglevel' , args .loglevel ,
57- ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
50+ node_bin ,
51+ node_gyp ,
52+ 'rebuild' ,
53+ '--directory' , test_dir ,
54+ '--nodedir' , headers_dir ,
55+ '--python' , sys .executable ,
56+ '--loglevel' , args .loglevel ,
57+ ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True )
5858
5959 # We buffer the output and print it out once the process is done in order
6060 # to avoid interleaved output from multiple builds running at once.
6161 return_code = process .wait ()
6262 stdout , stderr = process .communicate ()
6363 if return_code != 0 :
64- print (f'Failed to build addon in { test_dir } :' )
64+ print (f'Failed to build addon in { test_dir } . Check build.log for details.' )
65+
66+ build_dir = os .path .join (test_dir , 'logs' )
67+ os .makedirs (build_dir , exist_ok = True )
68+ log_file_path = os .path .join (build_dir , 'build.log' )
69+ with open (log_file_path , 'w' ) as log_file :
6570 if stdout :
66- print (stdout .decode ())
71+ print (stdout )
72+ log_file .write (stdout )
6773 if stderr :
68- print (stderr .decode ())
74+ print (stderr )
75+ log_file .write (stderr )
76+
6977 return return_code
7078
7179 except Exception as e :
0 commit comments