Skip to content

Commit

Permalink
feat(//py): setup.py now searches for bazel executable
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
  • Loading branch information
narendasan committed Jul 16, 2020
1 parent ea5ff08 commit 737fe5c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,27 @@
sys.argv.remove("--use-cxx11-abi")
CXX11_ABI = True

def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file

return None

BAZEL_EXE = which("bazel")

def build_libtrtorch_pre_cxx11_abi(develop=True, use_dist_dir=True, cxx11_abi=False):
cmd = ["/usr/bin/bazel", "build"]
cmd = [BAZEL_EXE, "build"]
cmd.append("//cpp/api/lib:libtrtorch.so")
if develop:
cmd.append("--compilation_mode=dbg")
Expand Down

0 comments on commit 737fe5c

Please sign in to comment.