Skip to content

Commit d075514

Browse files
ssjhvSung Jin Hwang
authored andcommitted
Add pip package building script. Based on tensorflow/custom-op.
PiperOrigin-RevId: 246424128 Change-Id: If4ea5c02d89e5611ba218e0302d4dbe2e5fefcbd
1 parent 43c13ba commit d075514

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ py_library(
4949
],
5050
)
5151

52+
sh_binary(
53+
name = "build_pip_pkg",
54+
srcs = ["build_pip_pkg.sh"],
55+
data = [
56+
"LICENSE",
57+
"MANIFEST.in",
58+
"README.md",
59+
"setup.py",
60+
":tensorflow_compression",
61+
],
62+
)
63+
5264
py_test(
5365
name = "entropy_models_test",
5466
timeout = "long",

build_pip_pkg.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018 The TensorFlow Authors. 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 is based on
18+
# https://github.com/tensorflow/custom-op/blob/master/build_pip_pkg.sh
19+
20+
set -e
21+
set -x
22+
23+
PIP_FILE_PREFIX="bazel-bin/build_pip_pkg.runfiles/__main__/"
24+
25+
function main() {
26+
DEST=${1}
27+
if [[ -z ${DEST} ]]; then
28+
DEST=/tmp
29+
fi
30+
31+
mkdir -p ${DEST}
32+
DEST=$(readlink -f "${DEST}")
33+
echo "=== destination directory: ${DEST}"
34+
35+
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
36+
echo $(date) : "=== Using tmpdir: ${TMPDIR}"
37+
38+
echo "=== Copying files"
39+
rsync -avm -L --exclude='*_test.py' --exclude='build_pip_pkg*' ${PIP_FILE_PREFIX} "${TMPDIR}"
40+
41+
echo $(date) : "=== Building wheel"
42+
pushd ${TMPDIR}
43+
python setup.py bdist_wheel > /dev/null
44+
cp dist/*.whl "${DEST}"
45+
popd
46+
47+
rm -rf ${TMPDIR}
48+
echo $(date) : "=== Output wheel file is in: ${DEST}"
49+
}
50+
51+
main "$@"

0 commit comments

Comments
 (0)