From ee23fc3d2e1898bb712b67aa5f3f2a891695d444 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 28 Jan 2019 10:47:12 -0800 Subject: [PATCH] Avoid 'which' failure --- third_party/py/python_configure.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 6e25cc493b3..9036a95909b 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -139,7 +139,12 @@ def _symlink_genrule_for_dir(repository_ctx, def _get_python_bin(repository_ctx): """Gets the python bin path.""" python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python') - python_bin_path = repository_ctx.which(python_bin) + if not '/' in python_bin and not '\\' in python_bin: + # It's a command, use 'which' to find its path. + python_bin_path = repository_ctx.which(python_bin) + else: + # It's a path, use it as it is. + python_bin_path = python_bin if python_bin_path != None: return str(python_bin_path) _fail("Cannot find python in PATH, please make sure " +