aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/git
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2018-01-03 17:01:21 +0100
committerGravatar Gunhan Gulsoy <gunan@google.com>2018-01-03 08:01:21 -0800
commit8c2d6fc2b0202304885d5d6c3cba57eb2a1b3262 (patch)
tree5e6f3ceee8cd7618e6c429c01cca69eaf6c43af5 /third_party/git
parent510e521edea2b3ad7a65542336930710d3dddf09 (diff)
Fix git configuration on Windows (#15814)
Diffstat (limited to 'third_party/git')
-rw-r--r--third_party/git/git_configure.bzl39
1 files changed, 37 insertions, 2 deletions
diff --git a/third_party/git/git_configure.bzl b/third_party/git/git_configure.bzl
index bd197bfd24..47e2125854 100644
--- a/third_party/git/git_configure.bzl
+++ b/third_party/git/git_configure.bzl
@@ -1,4 +1,31 @@
-"""Repository rule for Git autoconfiguration."""
+"""Repository rule for Git autoconfiguration.
+
+`git_configure` depends on the following environment variables:
+
+ * `PYTHON_BIN_PATH`: location of python binary.
+"""
+
+_PYTHON_BIN_PATH = "PYTHON_BIN_PATH"
+
+def _fail(msg):
+ """Output failure message when auto configuration fails."""
+ red = "\033[0;31m"
+ no_color = "\033[0m"
+ fail("%sGit Configuration Error:%s %s\n" % (red, no_color, msg))
+
+def _get_python_bin(repository_ctx):
+ """Gets the python bin path."""
+ python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH)
+ if python_bin != None:
+ return python_bin
+ python_bin_path = repository_ctx.which("python")
+ if python_bin_path != None:
+ return str(python_bin_path)
+ _fail("Cannot find python in PATH, please make sure " +
+ "python is installed and add its directory in PATH, or --define " +
+ "%s='/something/else'.\nPATH=%s" % (
+ _PYTHON_BIN_PATH, repository_ctx.os.environ.get("PATH", "")))
+
def _git_conf_impl(repository_ctx):
repository_ctx.template(
@@ -11,10 +38,18 @@ def _git_conf_impl(repository_ctx):
Label("@org_tensorflow//tensorflow/tools/git:gen_git_source.py"))
generated_files_path = repository_ctx.path("gen")
- repository_ctx.execute([
+ result = repository_ctx.execute([
+ _get_python_bin(repository_ctx),
python_script_path, "--configure", tensorflow_root_path,
"--gen_root_path", generated_files_path], quiet=False)
+ if not result.return_code == 0:
+ _fail(result.stderr)
+
+
git_configure = repository_rule(
implementation = _git_conf_impl,
+ environ = [
+ _PYTHON_BIN_PATH,
+ ],
)