From 568e13953774d9d827954fc9103c3d1778adfb11 Mon Sep 17 00:00:00 2001 From: htuch Date: Tue, 12 May 2020 17:23:09 -0400 Subject: [PATCH] build: add support for pip3_import from rules_python. (#11108) Provide an Envoy build system styled way of loading arbitrary pip3 packages as py_{library,binary} dependencies. Part of https://github.com/envoyproxy/envoy/issues/11085 (to fetch PyYAML). Risk level: Low (build system) Testing: Manual validation that the test utility loads PyYAML at the correct version (different to my system version). Signed-off-by: Harvey Tuch --- WORKSPACE | 4 +++ bazel/EXTERNAL_DEPS.md | 27 ++++++++++++++++--- bazel/dependency_imports.bzl | 3 +++ bazel/repositories.bzl | 4 +-- bazel/repositories_extra.bzl | 16 +++++++++++ bazel/repository_locations.bzl | 7 +++-- ci/WORKSPACE.filter.example | 4 +++ ci/run_envoy_docker_windows.sh | 2 +- tools/config_validation/BUILD | 10 +++++++ tools/config_validation/requirements.txt | 1 + .../validate_yaml_fragment.py | 3 +++ 11 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 bazel/repositories_extra.bzl create mode 100644 tools/config_validation/BUILD create mode 100644 tools/config_validation/requirements.txt create mode 100644 tools/config_validation/validate_yaml_fragment.py diff --git a/WORKSPACE b/WORKSPACE index ef120bc53d4f..a96cba501302 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,6 +12,10 @@ load("//bazel:repositories.bzl", "envoy_dependencies") envoy_dependencies() +load("//bazel:repositories_extra.bzl", "envoy_dependencies_extra") + +envoy_dependencies_extra() + load("//bazel:dependency_imports.bzl", "envoy_dependency_imports") envoy_dependency_imports() diff --git a/bazel/EXTERNAL_DEPS.md b/bazel/EXTERNAL_DEPS.md index 7793129376aa..7eebe1c3ec2b 100644 --- a/bazel/EXTERNAL_DEPS.md +++ b/bazel/EXTERNAL_DEPS.md @@ -6,7 +6,9 @@ values can change when Github change their tar/gzip libraries breaking builds. Maintainer provided tarballs are more stable and the maintainer can provide the SHA256. -# Adding external dependencies to Envoy (native Bazel) +# Adding external dependencies to Envoy (C++) + +## Native Bazel This is the preferred style of adding dependencies that use Bazel for their build process. @@ -17,7 +19,7 @@ build process. `external_deps` attribute. 3. `bazel test //test/...` -# Adding external dependencies to Envoy (external CMake) +## External CMake (preferred) This is the preferred style of adding dependencies that use CMake for their build system. @@ -29,7 +31,8 @@ This is the preferred style of adding dependencies that use CMake for their buil `external_deps` attribute. 4. `bazel test //test/...` -# Adding external dependencies to Envoy (genrule repository) + +## genrule repository This is the newer style of adding dependencies with no upstream Bazel configs. It wraps the dependency's native build tooling in a Bazel-aware shell script, @@ -54,6 +57,24 @@ Dependencies between external libraries can use the standard Bazel dependency resolution logic, using the `$(location)` shell extension to resolve paths to binaries, libraries, headers, etc. +# Adding external dependencies to Envoy (Python) + +Python dependencies should be added via `pip3` and `rules_python`. The process +is: + +1. Define a `pip3_import()` pointing at your target `requirements.txt` in + [`bazel/repositories_extra.bzl`](repositories_extra.bzl) + +2. Add a `pip_install()` invocation in + [`bazel/dependency_imports.bzl`](dependency_imports.bzl). + +3. Add a `requirements("