Skip to content

Commit

Permalink
repo: Use python toolchains (envoyproxy#20432)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored May 23, 2022
1 parent 3eb27a7 commit d8f0f22
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
4 changes: 4 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ load("//bazel:repositories_extra.bzl", "envoy_dependencies_extra")

envoy_dependencies_extra()

load("//bazel:python_dependencies.bzl", "envoy_python_dependencies")

envoy_python_dependencies()

load("//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()
25 changes: 25 additions & 0 deletions bazel/python_dependencies.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@rules_python//python:pip.bzl", "pip_install", "pip_parse")
load("@python3_10//:defs.bzl", "interpreter")

def envoy_python_dependencies():
pip_parse(
name = "base_pip3",
python_interpreter_target = interpreter,
requirements_lock = "@envoy//tools/base:requirements.txt",
extra_pip_args = ["--require-hashes"],
)

# These need to use `pip_install`
pip_install(
# Note: dev requirements do *not* check hashes
python_interpreter_target = interpreter,
name = "dev_pip3",
requirements = "@envoy//tools/dev:requirements.txt",
)

pip_install(
name = "fuzzing_pip3",
python_interpreter_target = interpreter,
requirements = "@rules_fuzzing//fuzzing:requirements.txt",
extra_pip_args = ["--require-hashes"],
)
32 changes: 10 additions & 22 deletions bazel/repositories_extra.bzl
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
load("@emsdk//:deps.bzl", emsdk_deps = "deps")
load("@rules_python//python:pip.bzl", "pip_install", "pip_parse")
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
load("@proxy_wasm_cpp_host//bazel/cargo/wasmtime:crates.bzl", "wasmtime_fetch_remote_crates")
load("//bazel/external/cargo:crates.bzl", "raze_fetch_remote_crates")

# Python dependencies.
def _python_deps():
pip_parse(
name = "base_pip3",
requirements_lock = "@envoy//tools/base:requirements.txt",
extra_pip_args = ["--require-hashes"],
)

# These need to use `pip_install`
pip_install(
# Note: dev requirements do *not* check hashes
name = "dev_pip3",
requirements = "@envoy//tools/dev:requirements.txt",
)
pip_install(
name = "fuzzing_pip3",
requirements = "@rules_fuzzing//fuzzing:requirements.txt",
extra_pip_args = ["--require-hashes"],
)
# Python version for `rules_python`
PYTHON_VERSION = "3.10.2"

# Envoy deps that rely on a first stage of dependency loading in envoy_dependencies().
def envoy_dependencies_extra():
_python_deps()
def envoy_dependencies_extra(python_version = PYTHON_VERSION):
emsdk_deps()
raze_fetch_remote_crates()
wasmtime_fetch_remote_crates()

# Registers underscored Python minor version - eg `python3_10`
python_register_toolchains(
name = "python%s" % ("_".join(python_version.split(".")[:-1])),
python_version = python_version,
)
4 changes: 4 additions & 0 deletions ci/WORKSPACE.filter.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ load("@envoy//bazel:repositories_extra.bzl", "envoy_dependencies_extra")

envoy_dependencies_extra()

load("@envoy//bazel:python_dependencies.bzl", "envoy_python_dependencies")

envoy_python_dependencies()

load("@envoy//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()

0 comments on commit d8f0f22

Please sign in to comment.