Skip to content

Commit

Permalink
Allow generate_py_protobufs to find a custom protoc (#7936)
Browse files Browse the repository at this point in the history
Currently, the logic in `generate_py_protobufs` cannot find a custom `protoc` (even though it's supposed to be possible). Fixes:

1. Mark the `--protoc` flag as accepting an argument.
2. If the `--protoc` flag was not passed, try finding `PROTOC` in the environment.
3. (Existing behavior) Otherwise, fall back to `spawn.find_executable`.

Hat tip to @bobhancock for uncovering the problem(s).
  • Loading branch information
dlj-NaN committed Oct 2, 2020
1 parent 54bfa17 commit 344f28d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class generate_py_protobufs(Command):
('extra-proto-paths=', None,
'Additional paths to resolve imports in .proto files.'),

('protoc', None,
('protoc=', None,
'Path to a specific `protoc` command to use.'),
]
boolean_options = ['recurse']
Expand Down Expand Up @@ -127,6 +127,8 @@ def finalize_options(self):

self.ensure_string_list('proto_files')

if self.protoc is None:
self.protoc = os.getenv('PROTOC')
if self.protoc is None:
self.protoc = spawn.find_executable('protoc')

Expand Down

0 comments on commit 344f28d

Please sign in to comment.