Skip to content

Commit 1dbef61

Browse files
ssjhvcopybara-github
authored andcommitted
Updated the README.md to reflect the changes in the pip package build process.
Removed bazel targets that are no longer used. PiperOrigin-RevId: 597064517 Change-Id: I41068b0c588a8eda4f77f95ead75bfa013889132
1 parent 9948dba commit 1dbef61

File tree

8 files changed

+18
-80
lines changed

8 files changed

+18
-80
lines changed

BUILD

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,3 @@ py_library(
3636
"//tensorflow_compression/python/util:packed_tensors",
3737
],
3838
)
39-
40-
py_binary(
41-
name = "build_api_docs",
42-
srcs = ["tools/build_api_docs.py"],
43-
deps = [":tensorflow_compression"],
44-
)
45-
46-
py_binary(
47-
name = "build_pip_pkg",
48-
srcs = ["tools/build_pip_pkg.py"],
49-
data = [
50-
"LICENSE",
51-
"README.md",
52-
"MANIFEST.in",
53-
"requirements.txt",
54-
"tensorflow_compression/all_tests.py",
55-
":tensorflow_compression",
56-
# The following targets are for Python unit tests.
57-
"//tensorflow_compression/python/datasets:py_src",
58-
"//tensorflow_compression/python/distributions:py_src",
59-
"//tensorflow_compression/python/entropy_models:py_src",
60-
"//tensorflow_compression/python/layers:py_src",
61-
"//tensorflow_compression/python/ops:py_src",
62-
"//tensorflow_compression/python/util:py_src",
63-
],
64-
)

README.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ releases](https://github.com/tensorflow/compression/releases).
7575
To install TFC via `pip`, run the following command:
7676

7777
```bash
78-
pip install tensorflow-compression
78+
python -m pip install tensorflow-compression
7979
```
8080

8181
To test that the installation works correctly, you can run the unit tests with:
@@ -95,7 +95,7 @@ installed TensorFlow version. Run it in a cell before executing your Python
9595
code:
9696

9797
```
98-
!pip install tensorflow-compression~=$(pip show tensorflow | perl -p -0777 -e 's/.*Version: (\d+\.\d+).*/\1.0/sg')
98+
%pip install tensorflow-compression~=$(pip show tensorflow | perl -p -0777 -e 's/.*Version: (\d+\.\d+).*/\1.0/sg')
9999
```
100100

101101
Note: The binary packages of TFC are tied to TF with the same minor version
@@ -114,7 +114,7 @@ host. For instance, you can use a command line like this:
114114

115115
```bash
116116
docker run tensorflow/tensorflow:latest bash -c \
117-
"pip install tensorflow-compression &&
117+
"python -m pip install tensorflow-compression &&
118118
python -m tensorflow_compression.all_tests"
119119
```
120120

@@ -132,7 +132,7 @@ installs TensorFlow and TensorFlow Compression:
132132
```bash
133133
conda create --name ENV_NAME python cudatoolkit cudnn
134134
conda activate ENV_NAME
135-
pip install tensorflow-compression
135+
python -m pip install tensorflow-compression
136136
```
137137

138138
Depending on the requirements of the `tensorflow` pip package, you may need to
@@ -257,22 +257,19 @@ that TensorFlow uses.
257257
Inside the Docker container, the following steps need to be taken:
258258

259259
1. Clone the `tensorflow/compression` repo from GitHub.
260-
2. Install Python dependencies.
261-
3. Run `:build_pip_pkg` inside the cloned repo.
260+
2. Run `tools/build_pip_pkg.sh` inside the cloned repo.
262261

263262
For example:
264263

265264
```bash
266-
sudo docker run -i --rm -v /tmp/tensorflow_compression:/tmp/tensorflow_compression \
267-
tensorflow/build:latest-python3.10 bash -c \
268-
"git clone https://github.com/tensorflow/compression.git /tensorflow_compression &&
269-
cd /tensorflow_compression &&
270-
python -m pip install -U pip setuptools wheel &&
271-
python -m pip install -r requirements.txt &&
272-
bazel build -c opt --copt=-mavx [email protected]_manylinux2014-cuda11.2-cudnn8.1-tensorrt7.2_config_cuda//crosstool:toolchain :build_pip_pkg &&
273-
pushd bazel-bin/build_pip_pkg.runfiles/tensorflow_compression &&
274-
python build_pip_pkg.py . /tmp/tensorflow_compression <custom-version> &&
275-
popd"
265+
git clone https://github.com/tensorflow/compression.git /tensorflow_compression
266+
docker run -i --rm \
267+
-v /tmp/tensorflow_compression:/tmp/tensorflow_compression\
268+
-v /tensorflow_compression:/tensorflow_compression \
269+
-w /tensorflow_compression \
270+
-e "BAZEL_OPT=--config=manylinux_2_17_x86_64" \
271+
tensorflow/build:latest-python3.10 \
272+
bash tools/build_pip_pkg.sh /tmp/tensorflow_compression <custom-version>
276273
```
277274

278275
For Darwin, the Docker image and specifying the toolchain is not necessary. We
@@ -282,20 +279,17 @@ Python virtual environment to do this):
282279
```bash
283280
git clone https://github.com/tensorflow/compression.git /tensorflow_compression
284281
cd /tensorflow_compression
285-
python -m pip install -U pip setuptools wheel
286-
python -m pip install -r requirements.txt
287-
bazel build -c opt --copt=-mavx --macos_minimum_os=10.14 :build_pip_pkg
288-
pushd bazel-bin/build_pip_pkg.runfiles/tensorflow_compression
289-
python build_pip_pkg.py . /tmp/tensorflow_compression <custom-version>"
290-
popd
282+
BAZEL_OPT="--macos_minimum_os=10.14" bash \
283+
tools/build_pip_pkg.sh \
284+
/tmp/tensorflow_compression <custom-version>
291285
```
292286

293287
In both cases, the wheel file is created inside `/tmp/tensorflow_compression`.
294288

295289
To test the created package, first install the resulting wheel file:
296290

297291
```bash
298-
pip install /tmp/tensorflow_compression/tensorflow_compression-*.whl
292+
python -m pip install /tmp/tensorflow_compression/tensorflow_compression-*.whl
299293
```
300294

301295
Then run the unit tests (Do not run the tests in the workspace directory where
@@ -312,7 +306,7 @@ popd
312306
When done, you can uninstall the pip package again:
313307

314308
```bash
315-
pip uninstall tensorflow-compression
309+
python -m pip uninstall tensorflow-compression
316310
```
317311

318312
## Evaluation

tensorflow_compression/python/datasets/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ py_test(
2323
srcs = ["y4m_dataset_test.py"],
2424
deps = [":y4m_dataset"],
2525
)
26-
27-
filegroup(
28-
name = "py_src",
29-
srcs = glob(["*.py"]),
30-
)

tensorflow_compression/python/distributions/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,3 @@ py_test(
8181
":round_adapters",
8282
],
8383
)
84-
85-
filegroup(
86-
name = "py_src",
87-
srcs = glob(["*.py"]),
88-
)

tensorflow_compression/python/entropy_models/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,3 @@ py_test(
104104
"//tensorflow_compression/python/distributions:uniform_noise",
105105
],
106106
)
107-
108-
filegroup(
109-
name = "py_src",
110-
srcs = glob(["*.py"]),
111-
)

tensorflow_compression/python/layers/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,3 @@ py_test(
8989
"//tensorflow_compression/python/ops:round_ops",
9090
],
9191
)
92-
93-
filegroup(
94-
name = "py_src",
95-
srcs = glob(["*.py"]),
96-
)

tensorflow_compression/python/ops/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,3 @@ py_test(
6868
srcs = ["quantization_ops_test.py"],
6969
deps = [":gen_ops"],
7070
)
71-
72-
filegroup(
73-
name = "py_src",
74-
srcs = glob(["*.py"]),
75-
)

tensorflow_compression/python/util/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,3 @@ py_test(
2222
srcs = ["packed_tensors_test.py"],
2323
deps = [":packed_tensors"],
2424
)
25-
26-
filegroup(
27-
name = "py_src",
28-
srcs = glob(["*.py"]),
29-
)

0 commit comments

Comments
 (0)