@@ -353,105 +353,109 @@ def main(generate_input, generate_output):
353353 raise Exception ("No package is generated, please check the log for details" )
354354
355355 # Now run the packaging phase that was previously in sdk_package.py
356- _LOGGER .info ("Starting packaging phase..." )
357-
358- sdk_folder = "."
359- final_result = {"packages" : []}
360-
361- for package in result .values ():
362- package_name = package ["packageName" ]
363- prefolder = package ["path" ][0 ]
356+ if len (result ) == 0 :
357+ _LOGGER .info ("No packages to process, returning empty result" )
358+ final_result = {"packages" : []}
359+ else :
360+ _LOGGER .info ("Starting packaging phase..." )
364361
365- # Changelog generation
366- last_version , last_stable_release = get_version_info (package_name , package ["tagIsStable" ])
367- change_log_func = partial (
368- change_log_generate ,
369- package_name ,
370- last_version ,
371- package ["tagIsStable" ],
372- last_stable_release = last_stable_release ,
373- prefolder = prefolder ,
374- is_multiapi = package ["isMultiapi" ],
375- )
376-
377- changelog_generation_start_time = time .time ()
378- try :
379- md_output = execute_func_with_timeout (change_log_func )
380- except multiprocessing .TimeoutError :
381- md_output = "change log generation was timeout!!! You need to write it manually!!!"
382- except :
383- md_output = "change log generation failed!!! You need to write it manually!!!"
384- finally :
385- for file in ["stable.json" , "current.json" ]:
386- file_path = Path (sdk_folder , prefolder , package_name , file )
387- if file_path .exists ():
388- os .remove (file_path )
389- _LOGGER .info (f"Remove { file_path } which is temp file to generate changelog." )
390-
391- _LOGGER .info (f"changelog generation cost time: { int (time .time () - changelog_generation_start_time )} seconds" )
392- package ["changelog" ] = {
393- "content" : md_output ,
394- "hasBreakingChange" : "Breaking Changes" in md_output ,
395- "breakingChangeItems" : extract_breaking_change (md_output ),
396- }
397- package ["version" ] = last_version
398-
399- _LOGGER .info (f"[PACKAGE]({ package_name } )[CHANGELOG]:{ md_output } " )
362+ sdk_folder = "."
363+ final_result = {"packages" : []}
400364
401- # Generate api stub File
402- folder_name = package ["path" ][0 ]
365+ for package in result .values ():
366+ package_name = package ["packageName" ]
367+ prefolder = package ["path" ][0 ]
368+
369+ # Changelog generation
370+ last_version , last_stable_release = get_version_info (package_name , package ["tagIsStable" ])
371+ change_log_func = partial (
372+ change_log_generate ,
373+ package_name ,
374+ last_version ,
375+ package ["tagIsStable" ],
376+ last_stable_release = last_stable_release ,
377+ prefolder = prefolder ,
378+ is_multiapi = package ["isMultiapi" ],
379+ )
403380
404- if package ["runInPipeline" ]:
405- apiview_start_time = time .time ()
381+ changelog_generation_start_time = time .time ()
406382 try :
407- package_path = Path (sdk_folder , folder_name , package_name )
408- check_call (
409- [
410- "python" ,
411- "-m" ,
412- "pip" ,
413- "install" ,
414- "-r" ,
415- "../../../eng/apiview_reqs.txt" ,
416- "--index-url=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi"
417- "/simple/" ,
418- ],
419- cwd = package_path ,
420- timeout = 600 ,
421- )
422- check_call (["apistubgen" , "--pkg-path" , "." ], cwd = package_path , timeout = 600 )
423- for file in os .listdir (package_path ):
424- if "_python.json" in file and package_name in file :
425- package ["apiViewArtifact" ] = str (Path (package_path , file ))
426- except Exception as e :
427- _LOGGER .debug (f"Fail to generate ApiView token file for { package_name } : { e } " )
428- _LOGGER .info (f"apiview generation cost time: { int (time .time () - apiview_start_time )} seconds" )
429- else :
430- _LOGGER .info ("Skip ApiView generation for package that does not run in pipeline." )
383+ md_output = execute_func_with_timeout (change_log_func )
384+ except multiprocessing .TimeoutError :
385+ md_output = "change log generation was timeout!!! You need to write it manually!!!"
386+ except :
387+ md_output = "change log generation failed!!! You need to write it manually!!!"
388+ finally :
389+ for file in ["stable.json" , "current.json" ]:
390+ file_path = Path (sdk_folder , prefolder , package_name , file )
391+ if file_path .exists ():
392+ os .remove (file_path )
393+ _LOGGER .info (f"Remove { file_path } which is temp file to generate changelog." )
394+
395+ _LOGGER .info (f"changelog generation cost time: { int (time .time () - changelog_generation_start_time )} seconds" )
396+ package ["changelog" ] = {
397+ "content" : md_output ,
398+ "hasBreakingChange" : "Breaking Changes" in md_output ,
399+ "breakingChangeItems" : extract_breaking_change (md_output ),
400+ }
401+ package ["version" ] = last_version
402+
403+ _LOGGER .info (f"[PACKAGE]({ package_name } )[CHANGELOG]:{ md_output } " )
404+
405+ # Generate api stub File
406+ folder_name = package ["path" ][0 ]
407+
408+ if package ["runInPipeline" ]:
409+ apiview_start_time = time .time ()
410+ try :
411+ package_path = Path (sdk_folder , folder_name , package_name )
412+ check_call (
413+ [
414+ "python" ,
415+ "-m" ,
416+ "pip" ,
417+ "install" ,
418+ "-r" ,
419+ "../../../eng/apiview_reqs.txt" ,
420+ "--index-url=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi"
421+ "/simple/" ,
422+ ],
423+ cwd = package_path ,
424+ timeout = 600 ,
425+ )
426+ check_call (["apistubgen" , "--pkg-path" , "." ], cwd = package_path , timeout = 600 )
427+ for file in os .listdir (package_path ):
428+ if "_python.json" in file and package_name in file :
429+ package ["apiViewArtifact" ] = str (Path (package_path , file ))
430+ except Exception as e :
431+ _LOGGER .debug (f"Fail to generate ApiView token file for { package_name } : { e } " )
432+ _LOGGER .info (f"apiview generation cost time: { int (time .time () - apiview_start_time )} seconds" )
433+ else :
434+ _LOGGER .info ("Skip ApiView generation for package that does not run in pipeline." )
431435
432- # check generated files and update package["version"]
433- if package_name .startswith ("azure-mgmt-" ):
434- try :
435- check_file (package )
436- except Exception as e :
437- _LOGGER .error (f"Fail to check generated files for { package_name } : { e } " )
438-
439- # Built package
440- create_package (prefolder , package_name )
441- dist_path = Path (sdk_folder , folder_name , package_name , "dist" )
442- package ["artifacts" ] = [str (dist_path / package_file ) for package_file in os .listdir (dist_path )]
443- for artifact in package ["artifacts" ]:
444- if ".whl" in artifact :
445- package ["language" ] = "Python"
446- break
447- # Installation package
448- package ["installInstructions" ] = {
449- "full" : "You can install the use using pip install of the artifacts." ,
450- "lite" : f"pip install { package_name } " ,
451- }
452- package ["result" ] = "succeeded"
453- package ["packageFolder" ] = package ["path" ][0 ]
454- final_result ["packages" ].append (package )
436+ # check generated files and update package["version"]
437+ if package_name .startswith ("azure-mgmt-" ):
438+ try :
439+ check_file (package )
440+ except Exception as e :
441+ _LOGGER .error (f"Fail to check generated files for { package_name } : { e } " )
442+
443+ # Built package
444+ create_package (prefolder , package_name )
445+ dist_path = Path (sdk_folder , folder_name , package_name , "dist" )
446+ package ["artifacts" ] = [str (dist_path / package_file ) for package_file in os .listdir (dist_path )]
447+ for artifact in package ["artifacts" ]:
448+ if ".whl" in artifact :
449+ package ["language" ] = "Python"
450+ break
451+ # Installation package
452+ package ["installInstructions" ] = {
453+ "full" : "You can install the use using pip install of the artifacts." ,
454+ "lite" : f"pip install { package_name } " ,
455+ }
456+ package ["result" ] = "succeeded"
457+ package ["packageFolder" ] = package ["path" ][0 ]
458+ final_result ["packages" ].append (package )
455459
456460 with open (generate_output , "w" ) as writer :
457461 json .dump (final_result , writer )
0 commit comments