summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <masotoudeh@ucdavis.edu>2020-09-22 20:51:35 -0700
committerGitHub <noreply@github.com>2020-09-22 20:51:35 -0700
commitbf2b329302f283d2d71eabf924d3b23186cb833e (patch)
tree7936b1325d23967b6f980c1a81e9e0dcb8f202b5
parent938df280646d1dc4e50c17f8949f5c247597e125 (diff)
If pip install fails, the corresponding Bazel rule should also fail. (#11)
Resolves Issue #10
-rw-r--r--bazel_python.bzl10
-rwxr-xr-xpywrapper.sh2
2 files changed, 6 insertions, 6 deletions
diff --git a/bazel_python.bzl b/bazel_python.bzl
index 44f9fea..60950be 100644
--- a/bazel_python.bzl
+++ b/bazel_python.bzl
@@ -88,11 +88,11 @@ def _bazel_python_venv_impl(ctx):
export PATH={py_dir}/lib:$PATH
export PATH={py_dir}/share:$PATH
export PYTHON_PATH={py_dir}:{py_dir}/bin:{py_dir}/include:{py_dir}/lib:{py_dir}/share
- python3 -m venv {out_dir}
- source {out_dir}/bin/activate
+ python3 -m venv {out_dir} || exit 1
+ source {out_dir}/bin/activate || exit 1
"""
if ctx.attr.requirements_file:
- command += "pip3 install -r " + ctx.file.requirements_file.path
+ command += "pip3 install -r " + ctx.file.requirements_file.path + " || exit 1"
inputs.append(ctx.file.requirements_file)
for src in ctx.attr.run_after_pip_srcs:
inputs.extend(src.files.to_list())
@@ -102,8 +102,8 @@ def _bazel_python_venv_impl(ctx):
REPLACEWITH='$PWD/bazel_python_venv_installed'
# This prevents sed from trying to modify the directory. We may want to
# do a more targeted sed in the future.
- rm -rf {out_dir}/bin/__pycache__
- sed -i'' -e s:$REPLACEME:$REPLACEWITH:g {out_dir}/bin/*
+ rm -rf {out_dir}/bin/__pycache__ || exit 1
+ sed -i'' -e s:$REPLACEME:$REPLACEWITH:g {out_dir}/bin/* || exit 1
"""
ctx.actions.run_shell(
command = command.format(py_dir = python_dir, out_dir = venv_dir.path),
diff --git a/pywrapper.sh b/pywrapper.sh
index a1ea558..6a7e99d 100755
--- a/pywrapper.sh
+++ b/pywrapper.sh
@@ -1,4 +1,4 @@
#!/bin/bash
-source bazel_python_venv_installed/bin/activate
+source bazel_python_venv_installed/bin/activate || exit 1
python $@
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback