blob: 1382950b999b49b0de759054b7ce186d9016b7f8 [file] [log] [blame]
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Recipe for downloading and packaging libtensorflow."""
from recipe_engine.recipe_api import Property
DEPS = [
"fuchsia/cipd_util",
"fuchsia/status_check",
"recipe_engine/archive",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/step",
"recipe_engine/url",
]
PROPERTIES = {"version": Property(kind=str, help="version", default="1.15.0")}
# These target spellings are used by libtensorflow.
PLATFORMS_TO_TARGETS = {
"linux-amd64": "linux-x86_64",
"mac-amd64": "darwin-x86_64",
"windows-amd64": "windows-x86_64",
}
PLATFORMS = sorted(PLATFORMS_TO_TARGETS.keys())
URL_TEMPLATE = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-{0}-{1}.{2}"
def RunSteps(api, version):
for platform in PLATFORMS:
with api.step.nest(platform):
extension = "zip" if platform.startswith("windows") else "tar.gz"
pkg_url = URL_TEMPLATE.format(
PLATFORMS_TO_TARGETS[platform], version, extension
)
pkg_file = api.path["start_dir"].join(
"libtensorflow-%s.%s" % (platform, extension)
)
api.url.get_file(pkg_url, pkg_file, step_name="fetch libtensorflow")
pkg_dir = api.path["start_dir"].join("libtensorflow-%s" % platform)
api.archive.extract("extract libtensorflow", pkg_file, pkg_dir)
api.cipd_util.upload_package(
"fuchsia/third_party/libtensorflow/%s" % platform,
pkg_dir,
search_tag={"version": version},
)
def GenTests(api):
yield api.status_check.test("basic") + api.properties(version="2.5.0")