|
| 1 | +load("//:gapic_generator_python.bzl", "pandoc_binary", "pandoc_toolchain") |
1 | 2 | load("@gapic_generator_python_pip_deps//:requirements.bzl", "requirement") |
| 3 | +load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") |
| 4 | + |
| 5 | +toolchain_type( |
| 6 | + name = "pandoc_toolchain_type", |
| 7 | + visibility = ["//visibility:public"], |
| 8 | +) |
| 9 | + |
| 10 | +pandoc_toolchain( |
| 11 | + exec_compatible_with = [ |
| 12 | + "@bazel_tools//platforms:linux", |
| 13 | + "@bazel_tools//platforms:x86_64", |
| 14 | + ], |
| 15 | + platform = "linux", |
| 16 | +) |
| 17 | + |
| 18 | +pandoc_toolchain( |
| 19 | + exec_compatible_with = [ |
| 20 | + "@bazel_tools//platforms:osx", |
| 21 | + "@bazel_tools//platforms:x86_64", |
| 22 | + ], |
| 23 | + platform = "macOS", |
| 24 | +) |
| 25 | + |
| 26 | +pandoc_binary( |
| 27 | + name = "pandoc_binary", |
| 28 | +) |
| 29 | + |
| 30 | +config_setting( |
| 31 | + name = "gapic_gen_python_3_6", |
| 32 | + values = {"define": "gapic_gen_python=3.6"}, |
| 33 | +) |
| 34 | + |
| 35 | +py_runtime( |
| 36 | + name = "pyenv3_runtime", |
| 37 | + interpreter = ":pyenv3wrapper.sh", |
| 38 | + python_version="PY3", |
| 39 | +) |
| 40 | + |
| 41 | +py_runtime_pair( |
| 42 | + name = "pyenv3_runtime_pair", |
| 43 | + py3_runtime = ":pyenv3_runtime", |
| 44 | +) |
| 45 | + |
| 46 | +toolchain( |
| 47 | + name = "pyenv3_toolchain", |
| 48 | + toolchain = ":pyenv3_runtime_pair", |
| 49 | + toolchain_type = "@bazel_tools//tools/python:toolchain_type", |
| 50 | +) |
2 | 51 |
|
3 | 52 | py_binary( |
4 | 53 | name = "gapic_plugin", |
5 | 54 | srcs = glob(["gapic/**/*.py"]), |
6 | | - data = glob(["gapic/**/*.j2"]), |
7 | | - main = "gapic/cli/generate.py", |
| 55 | + data = [":pandoc_binary"] + glob(["gapic/**/*.j2"]), |
| 56 | + main = "gapic/cli/generate_with_pandoc.py", |
| 57 | + python_version = "PY3", |
8 | 58 | visibility = ["//visibility:public"], |
9 | 59 | deps = [ |
10 | 60 | "@com_google_protobuf//:protobuf_python", |
| 61 | + "@com_github_grpc_grpc//src/python/grpcio/grpc:grpcio", |
11 | 62 | requirement("click"), |
12 | 63 | requirement("google-api-core"), |
13 | 64 | requirement("googleapis-common-protos"), |
14 | | - requirement("grpcio"), |
15 | 65 | requirement("jinja2"), |
16 | 66 | requirement("MarkupSafe"), |
17 | 67 | requirement("pypandoc"), |
18 | 68 | requirement("PyYAML"), |
19 | | - ], |
20 | | - python_version = "PY3", |
| 69 | + ] + select({ |
| 70 | + ":gapic_gen_python_3_6": [requirement("dataclasses")], |
| 71 | + "//conditions:default": [], |
| 72 | + }), |
21 | 73 | ) |
0 commit comments