onnxruntime/tools/nuget/create_nuspect.py
Scott McKay 5e0928a777
Enable running PEP8 on python scripts using flake8 (#3928)
* Enable running PEP8 checks via flake8 as part of the build if flake8 is installed.
Update scripts in \tools and \onnxruntime\python. Excluding \onnxruntime\python\tools which needs a lot more work to be PEP8 compliant. Also excluding orttraining\tools for the same reason.
Install flake8 as part of the static_analysis build task in the Win-CPU CI so the checks are run in one CI build.
Update coding standards doc.
2020-05-15 07:15:06 +10:00

46 lines
1.7 KiB
Python

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import argparse
import sys
def parse_arguments():
parser = argparse.ArgumentParser(description="ONNX Runtime create nuget spec script",
usage='')
# Main arguments
parser.add_argument("--source_dir", required=True, help="Path to the source directory.")
parser.add_argument("--debug_binary_root", required=True, help="Path to the debug binary directory.")
parser.add_argument("--release_binary_root", required=True, help="Path to the release binary directory.")
return parser.parse_args()
def generate_nuspec(source_dir, debug_binary_root, release_binary_root, architecture):
template_path = '%s/tools/nuget/template.nuspec' % source_dir
with open(template_path, 'rt') as f:
template = f.read()
return template.replace('@@DebugBinaryRoot@@', debug_binary_root)\
.replace('@@ReleaseBinaryRoot@@', release_binary_root)\
.replace('@@MSBuildArchitecture@@', architecture)\
.replace('@@SrcRoot@@', source_dir)
def generate_targets(source_dir):
template_path = '%s/tools/nuget/template.targets' % source_dir
with open(template_path, 'rt') as f:
template = f.read()
return template
def main():
args = parse_arguments()
nuspec = generate_nuspec(args.source_dir, args.debug_binary_root, args.release_binary_root, 'amd64')
with open('onnxruntime.nuspec', 'wt') as f:
f.write(nuspec)
targets = generate_targets(args.source_dir)
with open('onnxruntime.targets', 'wt') as f:
f.write(targets)
if __name__ == "__main__":
sys.exit(main())