diff options
author | Matthew Sotoudeh <masotoudeh@ucdavis.edu> | 2020-08-28 15:15:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-28 15:15:27 -0700 |
commit | e8207c27a2dbbed1f0a013717b32242478349d90 (patch) | |
tree | 8b8a4e4bf1dd14f4552ef46fc28ea229e970f603 | |
parent | 4e60f32823ad1326da45f7d29abc96de1c3ac9f0 (diff) |
Allow more complicated post-pip-install setup sequences (#8)
There's always been an option to run arbitrary code after the pip install step in order to set up the Python venv. However, that code could not use any other files from the current repository (so it was only useful for, e.g., downloading and installing something). This PR adds a new option, run_after_pip_srcs, which allows the user to specify a set of files which will be available to their post-install script.
I am using this to build + install a C++ module inside the venv.
-rw-r--r-- | bazel_python.bzl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bazel_python.bzl b/bazel_python.bzl index 990aec7..cd0bdd1 100644 --- a/bazel_python.bzl +++ b/bazel_python.bzl @@ -94,6 +94,8 @@ def _bazel_python_venv_impl(ctx): if ctx.attr.requirements_file: command += "pip3 install -r " + ctx.file.requirements_file.path inputs.append(ctx.file.requirements_file) + for src in ctx.attr.run_after_pip_srcs: + inputs.extend(src.files.to_list()) command += ctx.attr.run_after_pip command += """ REPLACEME=$PWD/'{out_dir}' @@ -116,6 +118,7 @@ bazel_python_venv = rule( "python_version": attr.string(), "requirements_file": attr.label(allow_single_file = True), "run_after_pip": attr.string(), + "run_after_pip_srcs": attr.label_list(allow_files = True), }, ) |