Skip to content

Commit 6505a6e

Browse files
authored
Update setup.py to allow pip install . (#959)
* Update setup.py Signed-off-by: Yong Tang <[email protected]> * Change BUILD to BUILD.bazel to avoid name collision on Windows Signed-off-by: Yong Tang <[email protected]> * Fix permission issue Signed-off-by: Yong Tang <[email protected]> * Updates README.md Signed-off-by: Yong Tang <[email protected]>
1 parent 322b317 commit 6505a6e

File tree

4 files changed

+149
-258
lines changed

4 files changed

+149
-258
lines changed

.kokorun/io_cpu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ docker run -i --rm -v $PWD:/v -w /v --net=host \
5656
-e BAZEL_OPTIMIZATION="${BAZEL_OPTIMIZATION}" \
5757
gcr.io/tensorflow-testing/nosla-ubuntu16.04-manylinux2010@sha256:3a9b4820021801b1fa7d0592c1738483ac7abc209fc6ee8c9ef06cf2eab2d170 /v/.github/workflows/build.bazel.sh
5858

59+
sudo chown -R $(id -nu):$(id -ng) .
60+
5961
docker run -i --rm --user $(id -u):$(id -g) -v /etc/password:/etc/password -v $PWD:/v -w /v --net=host \
6062
python:${PYTHON_VERSION}-slim python setup.py --data build -q bdist_wheel
6163

BUILD renamed to BUILD.bazel

File renamed without changes.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,34 @@ TFIO_DATAPATH=bazel-bin \
288288
'python3 -m pytest -s -v tests/test_serialization_eager.py'
289289
```
290290

291+
#### Python Wheels
292+
293+
It is possible to build python wheels after bazel build is complete with the following command:
294+
```
295+
python3 setup.py bdist_wheel --data bazel-bin
296+
```
297+
The whl file is will be available in dist directory. Note the bazel binary directory `bazel-bin`
298+
has to be passed with `--data` args in order for setup.py to locate the necessary share objects,
299+
as `bazel-bin` is outside of the `tensorflow_io` package directory.
300+
301+
Alternatively, source install could be done with:
302+
```
303+
TFIO_DATAPATH=bazel-bin python3 -m pip install .
304+
```
305+
with `TFIO_DATAPATH=bazel-bin` passed for the same readon.
306+
307+
Note installing with `-e` is different from the above. The
308+
```
309+
TFIO_DATAPATH=bazel-bin python3 -m pip install -e .
310+
```
311+
will not install shared object automatically even with `TFIO_DATAPATH=bazel-bin`. Instead,
312+
`TFIO_DATAPATH=bazel-bin` has to be passed everytime the program is run after the install:
313+
```
314+
TFIO_DATAPATH=bazel-bin python3
315+
# import tensorflow_io as tfio
316+
# ...
317+
```
318+
291319
#### Docker
292320

293321
For Python development, a reference Dockerfile [here](tools/dev/Dockerfile) can be

0 commit comments

Comments
 (0)