Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies: refactor with rules_python update #14329

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ build:remote --auth_enabled=true
build:remote --remote_download_toplevel

# Windows bazel does not allow sandboxed as a spawn strategy
build:remote-windows --action_env=WRAPT_INSTALL_EXTENSIONS=false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need this and the other change to this file

build:remote-windows --spawn_strategy=remote,local
build:remote-windows --strategy=Javac=remote,local
build:remote-windows --strategy=Closure=remote,local
Expand Down Expand Up @@ -295,6 +296,7 @@ build:compdb --build_tag_filters=-nocompdb

# Windows build quirks
build:windows --action_env=TMPDIR
build:windows --action_env=WRAPT_INSTALL_EXTENSIONS=false
build:windows --define signal_trace=disabled
build:windows --define hot_restart=disabled
build:windows --define tcmalloc=disabled
Expand Down
4 changes: 2 additions & 2 deletions DEPENDENCY_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Dependency declarations must:
be used if no CPE for the project is available in the CPE database. CPEs should be _versionless_
with a `:*` suffix, since the version can be computed from `version`.

When build or test code references Python modules, they should be imported via `pip3_import` in
[bazel/repositories_extra.bzl](bazel/repositories_extra.bzl). Python modules should not be listed in
When build or test code references Python modules, they should be imported via `pip_install` in
[bazel/dependency_imports.bzl](bazel/dependency_imports.bzl). Python modules should not be listed in
`repository_locations.bzl` entries. `requirements.txt` files for Python dependencies must pin to
exact versions, e.g. `PyYAML==5.3.1` and ideally also include a [SHA256
checksum](https://davidwalsh.name/hashin).
Expand Down
4 changes: 0 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ 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()
2 changes: 1 addition & 1 deletion api/bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
sha256 = "ebea8a6968722524d1bcc4426fb6a29907ddc2902aac7de1559012d3eee90cf9",
strip_prefix = "skywalking-data-collect-protocol-{version}",
urls = ["https://github.com/apache/skywalking-data-collect-protocol/archive/v{version}.tar.gz"],
release_date = "2020-07-29",
release_date = "2020-07-31",
use_category = ["api"],
),
)
11 changes: 4 additions & 7 deletions bazel/EXTERNAL_DEPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@ to binaries, libraries, headers, etc.

# Adding external dependencies to Envoy (Python)

Python dependencies should be added via `pip3` and `rules_python`. The process
Python dependencies should be added via `pip_install` 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)
1. Define a `pip_install()` pointing at your target `requirements.txt` in
[`bazel/dependency_imports.bzl`](bazel/dependency_imports.bzl)

2. Add a `pip_install()` invocation in
[`bazel/dependency_imports.bzl`](dependency_imports.bzl).

3. Add a `requirements("<package name")` in the `BUILD` file that depends on
2. Add a `requirements("<package name")` in the `BUILD` file that depends on
this package.

You can use [`tools/config_validation/BUILD`](../tools/config_validation/BUILD) as an example
Expand Down
149 changes: 120 additions & 29 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@envoy_build_tools//toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config")
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict", "custom_exec_properties")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict", "custom_exec_properties")
load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
load("@upb//bazel:repository_defs.bzl", upb_bazel_version_repository = "bazel_version_repository")
load("@envoy_build_tools//toolchains:rbe_toolchains_config.bzl", "rbe_toolchains_config")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
load("@config_validation_pip3//:requirements.bzl", config_validation_pip_install = "pip_install")
load("@configs_pip3//:requirements.bzl", configs_pip_install = "pip_install")
load("@headersplit_pip3//:requirements.bzl", headersplit_pip_install = "pip_install")
load("@kafka_pip3//:requirements.bzl", kafka_pip_install = "pip_install")
load("@protodoc_pip3//:requirements.bzl", protodoc_pip_install = "pip_install")
load("@thrift_pip3//:requirements.bzl", thrift_pip_install = "pip_install")
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_raze__fetch_remote_crates")
load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_dependencies")
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
load("@rules_python//python:pip.bzl", "pip_install")
load("@upb//bazel:repository_defs.bzl", upb_bazel_version_repository = "bazel_version_repository")

# go version for rules_go
GO_VERSION = "1.14.7"

def envoy_dependency_imports(go_version = GO_VERSION):
rules_foreign_cc_dependencies()
go_rules_dependencies()
apple_rules_dependencies()
go_register_toolchains(go_version)
rbe_toolchains_config()
gazelle_dependencies()
apple_rules_dependencies()
go_rules_dependencies()
proxy_wasm_cpp_host_raze__fetch_remote_crates()
proxy_wasm_rust_sdk_dependencies()
rbe_toolchains_config()
rules_foreign_cc_dependencies()
rust_repositories()
upb_bazel_version_repository(name = "upb_bazel_version")
antlr_dependencies(472)
proxy_wasm_rust_sdk_dependencies()

custom_exec_properties(
name = "envoy_large_machine_exec_property",
Expand All @@ -42,25 +39,119 @@ def envoy_dependency_imports(go_version = GO_VERSION):
name = "org_golang_google_grpc",
build_file_proto_mode = "disable",
importpath = "google.golang.org/grpc",
sum = "h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=",
version = "v1.29.1",
sum = "h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc=",
version = "v1.33.1",
# project_url = "https://pkg.go.dev/google.golang.org/grpc",
# last_update = "2020-10-21"
# use_category = ["api"],
# cpe = "cpe:2.3:a:grpc:grpc:*",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA=",
version = "v0.0.0-20190813141303-74dc4d7220e7",
sum = "h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=",
version = "v0.0.0-20201202161906-c7110b5ffcbb",
# project_url = "https://pkg.go.dev/mod/golang.org/x/net",
# last_update = "2020-12-02"
# use_category = ["api"],
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
version = "v0.3.0",
sum = "h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=",
version = "v0.3.4",
# project_url = "https://pkg.go.dev/mod/golang.org/x/text",
# last_update = "2020-10-27"
# use_category = ["api"],
)

pip_install(
name = "config_validation_pip3",
requirements = "@envoy//tools/config_validation:requirements.txt",
extra_pip_args = ["--require-hashes"],

# project_name = "PyYAML",
# project_url = "https://github.com/yaml/pyyaml",
# version = "5.3.1",
# last_update = "2020-03-18"
# use_category = ["devtools"],
# cpe = "cpe:2.3:a:pyyaml:pyyaml:*",
)
pip_install(
name = "configs_pip3",
requirements = "@envoy//configs:requirements.txt",
extra_pip_args = ["--require-hashes"],

# project_name = "Jinja",
# project_url = "http://palletsprojects.com/p/jinja",
# version = "2.11.2",
# last_update = "2020-04-13"
# use_category = ["test"],
# cpe = "cpe:2.3:a:palletsprojects:jinja:*",

# project_name = "MarkupSafe",
# project_url = "https://markupsafe.palletsprojects.com/en/1.1.x/",
# version = "1.1.1",
# last_update = "2019-02-23"
# use_category = ["test"],
)
pip_install(
name = "kafka_pip3",
requirements = "@envoy//source/extensions/filters/network/kafka:requirements.txt",
extra_pip_args = ["--require-hashes"],

config_validation_pip_install()
configs_pip_install()
headersplit_pip_install()
kafka_pip_install()
protodoc_pip_install()
thrift_pip_install()
# project_name = "Jinja",
# project_url = "http://palletsprojects.com/p/jinja",
# version = "2.11.2",
# last_update = "2020-04-13"
# use_category = ["test"],
# cpe = "cpe:2.3:a:palletsprojects:jinja:*",

# project_name = "MarkupSafe",
# project_url = "https://markupsafe.palletsprojects.com/en/1.1.x/",
# version = "1.1.1",
# last_update = "2019-02-23"
# use_category = ["test"],
)
pip_install(
name = "headersplit_pip3",
requirements = "@envoy//tools/envoy_headersplit:requirements.txt",
extra_pip_args = ["--require-hashes"],

# project_name = "Clang",
# project_url = "https://clang.llvm.org/",
# version = "10.0.1",
# last_update = "2020-07-21"
# use_category = ["devtools"],
# cpe = "cpe:2.3:a:llvm:clang:*",
)
pip_install(
name = "protodoc_pip3",
requirements = "@envoy//tools/protodoc:requirements.txt",
extra_pip_args = ["--require-hashes"],

# project_name = "PyYAML",
# project_url = "https://github.com/yaml/pyyaml",
# version = "5.3.1",
# last_update = "2020-03-18"
# use_category = ["devtools"],
# cpe = "cpe:2.3:a:pyyaml:pyyaml:*",
)
pip_install(
name = "thrift_pip3",
requirements = "@envoy//test/extensions/filters/network/thrift_proxy:requirements.txt",
extra_pip_args = ["--require-hashes"],

# project_name = "Apache Thrift",
# project_url = "http://thrift.apache.org/",
# version = "0.11.0",
# last_update = "2017-12-07"
# use_category = ["dataplane"],
# cpe = "cpe:2.3:a:apache:thrift:*",

# project_name = "Six: Python 2 and 3 Compatibility Library",
# project_url = "https://six.readthedocs.io/",
# version = "1.15.0",
# last_update = "2020-05-21"
# use_category = ["dataplane"],
)
2 changes: 1 addition & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _default_envoy_build_config = repository_rule(

# Python dependencies.
def _python_deps():
# TODO(htuch): convert these to pip3_import.
# TODO(htuch): convert these to pip_install.
external_http_archive(
name = "com_github_twitter_common_lang",
build_file = "@envoy//bazel/external:twitter_common_lang.BUILD",
Expand Down
104 changes: 0 additions & 104 deletions bazel/repositories_extra.bzl

This file was deleted.