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

No way to specify python_gapic_opt flag with py_gapic_library rule #390

Closed
aohren opened this issue Apr 14, 2020 · 5 comments
Closed

No way to specify python_gapic_opt flag with py_gapic_library rule #390

aohren opened this issue Apr 14, 2020 · 5 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@aohren
Copy link
Contributor

aohren commented Apr 14, 2020

We need to replicate the following protoc invocation from Bazel rule py_gapic_library. In particular, there's no current way to set --python_gapic_opt to the desired value below:

  protoc google/ads/googleads/${VERSION}/**/*.proto \
    --proto_path="${COMMON_PROTOS_PATH}" \
    --proto_path=. \
    --python_gapic_out=${OUTPUT_DIR} \
    --plugin=${GAPIC_GENERATOR_PATH}/gapic/cli/generate.py=python_gapic \
    --python_gapic_opt="old-naming,lazy-import,python-gapic-name=${GAPIC_NAME},python-gapic-templates=${GAPIC_GENERATOR_PATH}/gapic/ads-template"

where one var is custom:

GAPIC_NAME is googleads.

And the other vars are what you'd expect:

COMMON_PROTOS_PATH is api-common-protos dependencies
GAPIC_GENERATOR_PATH is root of gapic-generator-python

@aohren
Copy link
Contributor Author

aohren commented Apr 14, 2020

Output from a bazel build --verbose_failures run:

https://drive.google.com/a/google.com/file/d/1oKBkNbG6_wjwlNvS8F34CHQFBmLIpM8N/view?usp=sharing

@BenRKarl
Copy link
Contributor

@aohren there's an updated value for python-gapic-templates now, it should point to the /gapic/ads-templates directory on the master branch of this repository.

@aohren
Copy link
Contributor Author

aohren commented Apr 14, 2020

@BenRKarl thanks for that. I've edited the original issue in-place to reflect the updated protoc arguments.

@arithmetic1728 arithmetic1728 added the type: question Request for information or clarification. Not an issue. label Apr 14, 2020
vam-google added a commit that referenced this issue May 4, 2020
Shoud fix #400 and #390, plus a bunch of other not-yet-opened issues.

This includes:
1) Fix long initial load time (5+ min). This was caused by python_rules buildling `grpcio` dependency from sources in one core (which was super slow). Switched to using bazel-native `"@com_github_grpc_grpc//src/python/grpcio/grpc:grpcio"` target instead, which is not only much faster, but is also already used in googleapis, so there is no additional cost for reusing it in microgenerator rules.

2) Properly handle `pandoc` dependency (platform-sepcific version of pandoc is properly pulled by bazel itself using toolchains).

3) Add simplistic version of the `py_gapic_assembly_pkg` rule, to make output of microgenerator compatible with `GAPICBazel` class in synthtool.

4) Add `plugin_args` argument for python_gapic_library rule to pass custom argumetns to the plugin (similar to PHP rules).

5) Add compatibility with  `python3.6` runtime (otherwise `python3.7` is minimum because of dependency on `dataclasses` module). Python 3.6 compatibility can be enabled by adding `--define=gapic_gen_python=3.6` command line argument to `bazel build` command. 

6) Add support for Python runtimes installed with `pyenv`. To tell bazel using Python3 installed via pyenv add `--extra_toolchains=@gapic_generator_python//:pyenv3_toolchain` argument to `bazel build` command.
@vam-google vam-google self-assigned this May 8, 2020
vam-google added a commit to vam-google/gapic-generator-python that referenced this issue May 8, 2020
This is to suport <plugin_name>_opt command line args for protoc with a <plugin>.

See googleapis#390 for more details.
This PR depends on googleapis/gapic-generator#3191
vam-google added a commit that referenced this issue May 8, 2020
This is to suport <plugin_name>_opt command line args for protoc with a <plugin>.

See #390 for more details.
This PR depends on googleapis/gapic-generator#3191

Example of usage:
```bzl
py_gapic_library(
    name = "documentai_py_gapic",
    srcs = [":documentai_proto"],
    opt_args = [
        "old-naming",
        "lazy-import",
        "python-gapic-name=documentai",
        "python-gapic-templates=ads-templates",
    ],
)

```
@vam-google
Copy link
Contributor

Should be fixed in #411. Closing.

@software-dov
Copy link
Contributor

Should be fixed by #402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants