Skip to content

Commit

Permalink
lint runner
Browse files Browse the repository at this point in the history
  • Loading branch information
mszhanyi committed Dec 15, 2023
1 parent 332fce2 commit 168c8b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
33 changes: 26 additions & 7 deletions tools/nuget/generate_nuspec_for_native_nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<file src="' + str(child_file) + '" target="runtimes/win-%s/native"/>' % cpu_arch
)
Expand All @@ -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(
'<file src="' + str(child_file) + '" target="runtimes/linux-%s/native"/>' % cpu_arch
)
Expand Down Expand Up @@ -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('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
if package_name == "Microsoft.ML.OnnxRuntime.Gpu":
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Gpu-win"' + ' version="' + version + '"/>')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Gpu-linux"' + ' version="' + version + '"/>')


def generate_dependencies(xml_text, package_name, version):
dml_dependency = '<dependency id="Microsoft.AI.DirectML" version="1.12.1"/>'

Expand Down Expand Up @@ -409,19 +420,25 @@ def generate_files(line_list, args):
"<file src="
+ '"'
+ os.path.join(args.sources_path, "include\\onnxruntime\\core\\session\\onnxruntime_*.h")
+ '" target="' + include_dir + '" />'
+ '" target="'
+ include_dir
+ '" />'
)
files_list.append(
"<file src="
+ '"'
+ os.path.join(args.sources_path, "include\\onnxruntime\\core\\framework\\provider_options.h")
+ '" target="' + include_dir + '" />'
+ '" target="'
+ include_dir
+ '" />'
)
files_list.append(
"<file src="
+ '"'
+ os.path.join(args.sources_path, "include\\onnxruntime\\core\\providers\\cpu\\cpu_provider_factory.h")
+ '" target="' + include_dir + '" />'
+ '" target="'
+ include_dir
+ '" />'
)

if is_training_package:
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions tools/nuget/validate_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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":
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 168c8b7

Please sign in to comment.