mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-02 02:07:27 +00:00
* Work * Review update * Enabled tests * Bazel: Suppress warnings from external repositories * Fixed whl_test * Formatted * More format
61 lines
No EOL
2.2 KiB
Bash
Executable file
61 lines
No EOL
2.2 KiB
Bash
Executable file
#!/usr/bin/sh
|
|
|
|
# Copyright 2023 The TensorFlow Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Install the given tflm-micro.whl in a fresh virtual environment and run its
|
|
# embedded, post-installation checks.
|
|
|
|
set -e
|
|
|
|
WHL="${1}"
|
|
PYTHON_BIN="${2:-python3}"
|
|
|
|
# The py_wheel rule creates two outputs: the base :whl target with literal stamp
|
|
# variables in the filename (for Bazel caching), and :whl.dist with expanded
|
|
# variables. This test uses :whl as its data dependency because :whl.dist isn't
|
|
# a proper Bazel target that can be referenced in deps.
|
|
#
|
|
# Pip 25.x in Python 3.12+ strictly validates wheel filenames and rejects
|
|
# literal stamp variables like _BUILD_EMBED_LABEL_. To make this robust against
|
|
# any version string format (which might contain various placeholders), we
|
|
# simply rename the input wheel to a fixed, safe filename before installing.
|
|
# We don't care about the version string in the filename for this test, as pip
|
|
# installs the content anyway.
|
|
|
|
SAFE_WHL="tflite_micro-0.0.0-py3-none-any.whl"
|
|
cp "${WHL}" "${SAFE_WHL}"
|
|
|
|
# Create venv for this test.
|
|
"${PYTHON_BIN}" -m venv pyenv
|
|
. pyenv/bin/activate
|
|
|
|
# Disable pip's cache for two reasons: 1) the default location in
|
|
# $XDG_CACHE_HOME causes errors when pip is run from a bazel sandbox, and 2) it
|
|
# makes no sense to relocate the cache within the sandbox since files generated
|
|
# in the sandbox are deleted after the run.
|
|
export PIP_NO_CACHE_DIR=true
|
|
|
|
# Test package installation.
|
|
pip install "${SAFE_WHL}"
|
|
pip show --files tflite-micro
|
|
|
|
# Run the package's post-installation checks.
|
|
python3 << HEREDOC
|
|
import sys
|
|
import tflite_micro
|
|
from tflite_micro.python.tflite_micro import postinstall_check
|
|
print(tflite_micro.__version__)
|
|
sys.exit(0 if postinstall_check.passed() else 1)
|
|
HEREDOC |