Skip to content

Commit 4aa9583

Browse files
ssjhvcopybara-github
authored andcommitted
Use bash script instead of bazel to collect package files.
PiperOrigin-RevId: 591921581 Change-Id: I8d71e65be4cc9ed0909a231dd7e2ef7cc8e79d0e
1 parent 8137024 commit 4aa9583

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

build_pip_pkg.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Google LLC. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+

0 commit comments

Comments
 (0)