Skip to content

Commit 737fe5c

Browse files
committed
feat(//py): setup.py now searches for bazel executable
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent ea5ff08 commit 737fe5c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: py/setup.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,27 @@
2424
sys.argv.remove("--use-cxx11-abi")
2525
CXX11_ABI = True
2626

27+
def which(program):
28+
import os
29+
def is_exe(fpath):
30+
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
31+
32+
fpath, fname = os.path.split(program)
33+
if fpath:
34+
if is_exe(program):
35+
return program
36+
else:
37+
for path in os.environ["PATH"].split(os.pathsep):
38+
exe_file = os.path.join(path, program)
39+
if is_exe(exe_file):
40+
return exe_file
41+
42+
return None
43+
44+
BAZEL_EXE = which("bazel")
45+
2746
def build_libtrtorch_pre_cxx11_abi(develop=True, use_dist_dir=True, cxx11_abi=False):
28-
cmd = ["/usr/bin/bazel", "build"]
47+
cmd = [BAZEL_EXE, "build"]
2948
cmd.append("//cpp/api/lib:libtrtorch.so")
3049
if develop:
3150
cmd.append("--compilation_mode=dbg")

0 commit comments

Comments
 (0)