@@ -174,30 +174,40 @@ def test(session, library):
174
174
system (session )
175
175
176
176
177
- # @nox.session(python="3.8")
178
- # def generate_protos(session):
179
- # """Generates the protos using protoc.
180
- #
181
- # THIS SESSION CAN ONLY BE RUN LOCALLY
182
- # Clone `api-common-protos` in the parent directory
183
- #
184
- # Some notes on the `google` directory:
185
- # 1. The `_pb2.py` files are produced by protoc.
186
- # 2. The .proto files are non-functional but are left in the repository
187
- # to make it easier to understand diffs.
188
- # 3. The `google` directory also has `__init__.py` files to create proper modules.
189
- # If a new subdirectory is added, you will need to create more `__init__.py`
190
- # files.
191
- # """
192
- # session.install("grpcio-tools")
193
- # protos = [str(p) for p in (Path(".").glob("google/**/*.proto"))]
194
-
195
- # session.run(
196
- # "python",
197
- # "-m",
198
- # "grpc_tools.protoc",
199
- # "--proto_path=../api-common-protos",
200
- # "--proto_path=.",
201
- # "--python_out=.",
202
- # *protos,
203
- # )
177
+ @nox .session (python = "3.8" )
178
+ def generate_protos (session ):
179
+ """Generates the protos using protoc.
180
+
181
+ Some notes on the `google` directory:
182
+ 1. The `_pb2.py` files are produced by protoc.
183
+ 2. The .proto files are non-functional but are left in the repository
184
+ to make it easier to understand diffs.
185
+ 3. The `google` directory also has `__init__.py` files to create proper modules.
186
+ If a new subdirectory is added, you will need to create more `__init__.py`
187
+ files.
188
+ """
189
+ session .install ("grpcio-tools" )
190
+ protos = [str (p ) for p in (Path ("." ).glob ("google/**/*.proto" ))]
191
+
192
+ # Clone googleapis/api-common-protos
193
+ api_common_protos = "api-common-protos"
194
+ try :
195
+ session .run ("git" , "-C" , api_common_protos , "pull" , external = True )
196
+ except nox .command .CommandFailed :
197
+ session .run (
198
+ "git" ,
199
+ "clone" ,
200
+ "--single-branch" ,
201
+ f"https://github.com/googleapis/{ api_common_protos } " ,
202
+ external = True ,
203
+ )
204
+
205
+ session .run (
206
+ "python" ,
207
+ "-m" ,
208
+ "grpc_tools.protoc" ,
209
+ "--proto_path=api-common-protos" ,
210
+ "--proto_path=." ,
211
+ "--python_out=." ,
212
+ * protos ,
213
+ )
0 commit comments