21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'ext/onnx_ruby/extconf.rb', line 21
def download_onnxruntime(dest_dir)
platform = detect_platform
filename = "onnxruntime-#{platform}-#{ORT_VERSION}.tgz"
url = "https://github.com/microsoft/onnxruntime/releases/download/v#{ORT_VERSION}/#{filename}"
tmp_file = File.join(Dir.tmpdir, filename)
unless File.exist?(tmp_file)
puts "Downloading ONNX Runtime v#{ORT_VERSION} for #{platform}..."
system("curl", "-fSL", url, "-o", tmp_file) or
abort "Failed to download ONNX Runtime from #{url}"
end
FileUtils.mkdir_p(dest_dir)
puts "Extracting to #{dest_dir}..."
system("tar", "xzf", tmp_file, "-C", dest_dir, "--strip-components=1") or
abort "Failed to extract ONNX Runtime"
dest_dir
end
|