You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by jo...@apache.org on 2022/01/01 23:58:31 UTC

[incubator-heron] 01/01: updating python and docker rules as a start

This is an automated email from the ASF dual-hosted git repository.

joshfischer pushed a commit to branch joshfischer/native-python-rules
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git

commit 3d22655b8c4e14de810e3d068e6eb41fa876ddf5
Author: Josh Fischer <jo...@joshfischer.io>
AuthorDate: Sat Jan 1 17:58:08 2022 -0600

    updating python and docker rules as a start
---
 WORKSPACE                        | 27 ++++++++++++++-------------
 heron/tools/cli/src/python/BUILD | 18 ++++++++++++++++++
 tools/python/requirements.txt    |  3 +++
 tools/rules/genproto.bzl         |  3 ++-
 4 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/WORKSPACE b/WORKSPACE
index 7982cd7..87c7168 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -170,14 +170,21 @@ jar_jar_repositories()
 
 http_archive(
     name = "rules_python",
-    sha256 = "b5668cde8bb6e3515057ef465a35ad712214962f0b3a314e551204266c7be90c",
-    strip_prefix = "rules_python-0.0.2",
-    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.2/rules_python-0.0.2.tar.gz",
+    url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
+    sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
+)
+
+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",
 )
 
 load("@rules_python//python:repositories.bzl", "py_repositories")
 
-py_repositories()
+#py_repositories()
 # Only needed if using the packaging rules.
 # load("@rules_python//python:pip.bzl", "pip_repositories")
 # pip_repositories()
@@ -369,13 +376,11 @@ http_archive(
 # end helm
 
 # for docker image building
-DOCKER_RULES_VERSION = "0.14.4"
-
 http_archive(
     name = "io_bazel_rules_docker",
-    sha256 = "4521794f0fba2e20f3bf15846ab5e01d5332e587e9ce81629c7f96c793bb7036",
-    strip_prefix = "rules_docker-%s" % DOCKER_RULES_VERSION,
-    urls = ["https://github.com/bazelbuild/rules_docker/archive/v%s.tar.gz" % DOCKER_RULES_VERSION],
+    sha256 = "59536e6ae64359b716ba9c46c39183403b01eabfbd57578e84398b4829ca499a",
+    strip_prefix = "rules_docker-0.22.0",
+    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.22.0/rules_docker-v0.22.0.tar.gz"],
 )
 
 load(
@@ -388,10 +393,6 @@ load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")
 
 container_deps()
 
-load("@io_bazel_rules_docker//repositories:pip_repositories.bzl", "pip_deps")
-
-pip_deps()
-
 load(
     "@io_bazel_rules_docker//container:container.bzl",
     "container_pull",
diff --git a/heron/tools/cli/src/python/BUILD b/heron/tools/cli/src/python/BUILD
index e1c4594..feed1dc 100644
--- a/heron/tools/cli/src/python/BUILD
+++ b/heron/tools/cli/src/python/BUILD
@@ -1,5 +1,23 @@
+load("@rules_python//python:defs.bzl", "py_library")
+load("@heron_py_deps//:requirements.bzl", "requirement")
+
 package(default_visibility = ["//visibility:public"])
 
+py_library(
+  name = "cli_py_2",
+  srcs = glob(
+                 ["**/*.py"],
+             ),
+  deps = [
+      "//heron/common/src/python:common-py",
+      "//heron/proto:proto-py",
+      "//heron/tools/common/src/python:common-py",
+      requirement("PyYAML"),
+      requirement("requests"),
+      requirement("netifaces")
+  ]
+)
+
 pex_library(
     name = "cli-py",
     srcs = glob(
diff --git a/tools/python/requirements.txt b/tools/python/requirements.txt
new file mode 100644
index 0000000..2972a28
--- /dev/null
+++ b/tools/python/requirements.txt
@@ -0,0 +1,3 @@
+PyYAML==3.13
+requests==2.12.3
+netifaces==0.10.6
\ No newline at end of file
diff --git a/tools/rules/genproto.bzl b/tools/rules/genproto.bzl
index 9e4d3fc..faae697 100644
--- a/tools/rules/genproto.bzl
+++ b/tools/rules/genproto.bzl
@@ -18,6 +18,7 @@
 load("@rules_java//java:defs.bzl", "java_library")
 load("@rules_cc//cc:defs.bzl", "cc_library")
 load("//tools/rules/pex:pex_rules.bzl", "pex_library")
+load("@rules_python//python:defs.bzl", "py_binary")
 
 def proto_package_impl(ctx):
     return struct(proto_src = ctx.file.src)
@@ -182,7 +183,7 @@ def proto_library(
             srcs = proto_deps,
             cmd = proto_cmd,
         )
-        pex_library(
+        py_binary(
             name = proto_lib,
             visibility = visibility,
             srcs = [proto_src],