Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Native Python Build Rules - Phase 1 #3768

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,15 @@ http_archive(
url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
# Only needed if using the packaging rules.
# load("@rules_python//python:pip.bzl", "pip_repositories")
# pip_repositories()
load("@rules_python//python:pip.bzl", "pip_install")
# Create a central external repo, @heron_py_deps, that contains Bazel targets for all the
# third-party packages specified in the requirements.txt file.
pip_install(
name = "heron_py_deps",
requirements = "//tools/python:requirements.txt",
)


# for pex repos
PEX_PKG = "https://files.pythonhosted.org/packages/d4/73/4c76e06824baadba81b39125721c97fb22e201b35fcd17b32b5a5fa77c59/pex-2.1.62-py2.py3-none-any.whl"
Expand Down Expand Up @@ -515,3 +518,30 @@ load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "
scalatest_repositories()

scalatest_toolchain()

# Protocol buffers in Java and CC.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1",
strip_prefix = "rules_proto-4.0.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

# Protocol buffer for Python.
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "com_google_protobuf",
remote = "https://github.com/protocolbuffers/protobuf",
tag = "v3.10.0",
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
35 changes: 19 additions & 16 deletions examples/src/python/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package(default_visibility = ["//visibility:public"])

pex_library(
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_python//python:defs.bzl", "py_binary")

py_library(
name = "example-py",
srcs = glob([
"bolt/*.py",
Expand All @@ -13,45 +16,45 @@ pex_library(
)

# with main method
pex_binary(
py_binary(
name = "word_count",
srcs = ["word_count_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

pex_binary(
py_binary(
name = "half_acking",
srcs = ["half_acking_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

pex_binary(
py_binary(
name = "window_size",
srcs = ["window_size_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

pex_binary(
py_binary(
name = "stateful_word_count",
srcs = ["stateful_word_count_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

# without main method
pex_binary(
py_binary(
name = "custom_grouping",
srcs = ["custom_grouping_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

pex_binary(
py_binary(
name = "multi_stream",
srcs = ["multi_stream_topology.py"],
deps = [":example-py"],
deps = ["example-py"],
)

# streamlet API examples
pex_binary(
py_binary(
name = "word_count_streamlet",
srcs = ["word_count_streamlet.py"],
deps = [
Expand All @@ -61,7 +64,7 @@ pex_binary(
],
)

pex_binary(
py_binary(
name = "pulsar_word_count_streamlet",
srcs = ["pulsar_word_count_streamlet.py"],
deps = [
Expand All @@ -71,7 +74,7 @@ pex_binary(
],
)

pex_binary(
py_binary(
name = "join_streamlet_topology",
srcs = ["join_streamlet_topology.py"],
deps = [
Expand Down
5 changes: 4 additions & 1 deletion heron/common/tests/python/pex_loader/testdata/src/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package(default_visibility = ["//visibility:public"])

pex_binary(
load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
name = "sample_pex",
main = "sample.py",
srcs = ["sample.py"],
)
Empty file added tools/python/requirements.txt
Empty file.
185 changes: 0 additions & 185 deletions tools/rules/newgenproto.bzl

This file was deleted.