Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/python/grpcio_sleuth/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,27 @@
class custom_build_ext(build_ext):
def run(self):
# Discover the compiler.
compiler = sysconfig.get_config_var('CC')
if not compiler or compiler == 'gcc':
compiler = shutil.which('gcc') or shutil.which('clang') or shutil.which('cc')
compiler = sysconfig.get_config_var("CC")
if not compiler or compiler == "gcc":
compiler = (
shutil.which("gcc")
or shutil.which("clang")
or shutil.which("cc")
)

bazel_env = os.environ.copy()
if compiler:
print(f"Setting CC={compiler} for Bazel build")
bazel_env['CC'] = compiler
bazel_env["CC"] = compiler
else:
print("Warning: Could not find C compiler for Bazel")

# Run the bazel build command
bazel_cmd = [_BAZEL_PATH, "build", "//test/cpp/sleuth:sleuth.so"]
print(f"Running command: {' '.join(bazel_cmd)}")
result = subprocess.run(bazel_cmd, cwd=GRPC_ROOT, check=False, env=bazel_env)
result = subprocess.run(
bazel_cmd, cwd=GRPC_ROOT, check=False, env=bazel_env
)
if result.returncode != 0:
print("Bazel build failed!")
sys.exit(result.returncode)
Expand Down