|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2023 Google LLC. All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# ============================================================================== |
| 16 | + |
| 17 | +# This script must run at the workspace root directory. |
| 18 | +# In addition, `tensorflow_compression/cc:libtensorflow_compression.so` should |
| 19 | +# have been built using bazel. |
| 20 | + |
| 21 | +set -ex # Fail if any command fails, echo commands. |
| 22 | + |
| 23 | +OUTPUT_DIR="${1-/tmp}" |
| 24 | +WHEEL_VERSION="${2-0.dev0}" |
| 25 | + |
| 26 | +PKGDIR="$(mktemp -d)" |
| 27 | +trap 'rm -r -- "${PKGDIR}"' EXIT |
| 28 | + |
| 29 | +cp LICENSE README.md MANIFEST.in requirements.txt build_pip_pkg.py "${PKGDIR}" |
| 30 | + |
| 31 | +mkdir -p "${PKGDIR}/tensorflow_compression/cc" |
| 32 | +cp "$(bazel info -c opt bazel-genfiles)/tensorflow_compression/cc/libtensorflow_compression.so" \ |
| 33 | + "${PKGDIR}/tensorflow_compression/cc" |
| 34 | + |
| 35 | + |
| 36 | +copy_file() |
| 37 | +{ |
| 38 | + FILENAME="${1#./}" |
| 39 | + DEST="${PKGDIR%/}/$(dirname "${FILENAME}")" |
| 40 | + mkdir -p "${DEST}" |
| 41 | + cp "${FILENAME}" "${DEST}" |
| 42 | +} |
| 43 | + |
| 44 | +copy_file "tensorflow_compression/__init__.py" |
| 45 | +copy_file "tensorflow_compression/all_tests.py" |
| 46 | + |
| 47 | +# Assumes no irregular characters in the filenames. |
| 48 | +find tensorflow_compression/python -name "*.py" \ |
| 49 | + | while read filename; do copy_file "${filename}"; done |
| 50 | + |
| 51 | +pushd "${PKGDIR}" |
| 52 | +python build_pip_pkg.py . "${OUTPUT_DIR}" "${WHEEL_VERSION}" |
| 53 | +popd |
0 commit comments