From 168c8b7dd97e04c2dd46f6ec1c31484daa5f9143 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 10:16:54 +0800 Subject: [PATCH] lint runner --- .../nuget/generate_nuspec_for_native_nuget.py | 33 +++++++++++++++---- tools/nuget/validate_package.py | 11 ++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index d3905697df701..bf8a473ca8dc6 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -60,7 +60,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux": + if ( + child_file.suffix in suffixes + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux" + ): files_list.append( '' % cpu_arch ) @@ -86,7 +90,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win": + if ( + child_file.suffix == ".so" + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win" + ): files_list.append( '' % cpu_arch ) @@ -197,13 +205,16 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): - dependent_packages = bool(package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux") + dependent_packages = bool( + package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" + ) if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": xml_text.append('') xml_text.append('') + def generate_dependencies(xml_text, package_name, version): dml_dependency = '' @@ -409,19 +420,25 @@ def generate_files(line_list, args): "' + + '" target="' + + include_dir + + '" />' ) files_list.append( "' + + '" target="' + + include_dir + + '" />' ) files_list.append( "' + + '" target="' + + include_dir + + '" />' ) if is_training_package: @@ -554,7 +571,9 @@ def generate_files(line_list, args): else: ep_list = [None] for ep in ep_list: - generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, args.package_name) + generate_file_list_for_ep( + nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, args.package_name + ) is_ado_packaging_build = True else: # Code path for local dev build diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 2dfab4e7f0c58..ab7c8e9f44855 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -93,7 +93,6 @@ def check_if_headers_are_present(header_files, header_folder, file_list_in_packa raise Exception(header + " not found for " + platform) - def check_if_dlls_are_present( package_type, is_windows_ai_package, @@ -103,7 +102,7 @@ def check_if_dlls_are_present( platforms_supported, zip_file, package_path, - is_gpu_dependent_package = False, # only used for nuget packages + is_gpu_dependent_package=False, # only used for nuget packages ): platforms = platforms_supported.strip().split(",") if package_type == "tarball": @@ -143,7 +142,9 @@ def check_if_dlls_are_present( print(dll + " not found for " + platform) raise Exception(dll + " not found for " + platform) # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): + if (is_gpu_package and package_type != "nuget") or ( + package_type == "nuget" and not is_gpu_dependent_package + ): check_if_headers_are_present(gpu_related_header_files, header_folder, file_list_in_package, platform) if is_dml_package: @@ -180,7 +181,9 @@ def check_if_dlls_are_present( print(so + " not found for " + platform) raise Exception(so + " not found for " + platform) # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): + if (is_gpu_package and package_type != "nuget") or ( + package_type == "nuget" and not is_gpu_dependent_package + ): for header in gpu_related_header_files: path = header_folder + "/" + header print("Checking path: " + path)