AnandInguva commented on code in PR #28385:
URL: https://github.com/apache/beam/pull/28385#discussion_r1332157712


##########
sdks/python/setup.py:
##########
@@ -155,12 +156,18 @@ def cythonize(*args, **kwargs):
 # We must generate protos after setup_requires are installed.
 def generate_protos_first():
   try:
-    # pylint: disable=wrong-import-position
-    import gen_protos
-    gen_protos.generate_proto_files()
-
-  except ImportError:
-    warnings.warn("Could not import gen_protos, skipping proto generation.")
+    # Pyproject toml build happens in isolated environemnts. In those envs,
+    # gen_protos is unable to get imported. so we run a subprocess call.
+    cwd = os.path.abspath(os.path.dirname(__file__))
+    p = subprocess.call([
+      sys.executable,
+      os.path.join(cwd, 'gen_protos.py'),
+      '--no-force'

Review Comment:
   We don't want to generate stubs if they are already generated. This is the 
same as the old setup.



##########
sdks/python/setup.py:
##########
@@ -155,12 +156,18 @@ def cythonize(*args, **kwargs):
 # We must generate protos after setup_requires are installed.
 def generate_protos_first():
   try:
-    # pylint: disable=wrong-import-position
-    import gen_protos
-    gen_protos.generate_proto_files()
-
-  except ImportError:
-    warnings.warn("Could not import gen_protos, skipping proto generation.")
+    # Pyproject toml build happens in isolated environemnts. In those envs,
+    # gen_protos is unable to get imported. so we run a subprocess call.
+    cwd = os.path.abspath(os.path.dirname(__file__))
+    p = subprocess.call([
+      sys.executable,
+      os.path.join(cwd, 'gen_protos.py'),
+      '--no-force'

Review Comment:
   We don't want to generate stubs if they are already generated. This is the 
same behavior as the old setup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to