diff options
author | Sourabh Bajaj <sourabhbajaj@google.com> | 2017-11-30 16:37:11 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-11-30 16:41:01 -0800 |
commit | b2db981a6731e978453862a73dab892bc674db68 (patch) | |
tree | c11a7c4038e2595268113c2859c1d0d3072ede4f /third_party | |
parent | 0438ac79bdb503ed267bec2146e7136ac8e99ff9 (diff) |
Merge changes from github.
PiperOrigin-RevId: 177526301
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/flatbuffers/flatbuffers.BUILD | 7 | ||||
-rw-r--r-- | third_party/mkl/build_defs.bzl | 2 | ||||
-rw-r--r-- | third_party/nccl.BUILD | 2 | ||||
-rw-r--r-- | third_party/py/python_configure.bzl | 91 |
4 files changed, 43 insertions, 59 deletions
diff --git a/third_party/flatbuffers/flatbuffers.BUILD b/third_party/flatbuffers/flatbuffers.BUILD index e1563103c8..0a76adcf91 100644 --- a/third_party/flatbuffers/flatbuffers.BUILD +++ b/third_party/flatbuffers/flatbuffers.BUILD @@ -6,8 +6,11 @@ licenses(["notice"]) # Apache 2.0 FLATBUFFERS_COPTS = [ "-fexceptions", - "-Wno-implicit-fallthrough", -] +] + select({ + "@bazel_tools//src:windows": [], + "@bazel_tools//src:windows_msvc": [], + "//conditions:default": ["-Wno-implicit-fallthrough"], +}) # Public flatc library to compile flatbuffer files at runtime. cc_library( diff --git a/third_party/mkl/build_defs.bzl b/third_party/mkl/build_defs.bzl index f637873f14..8b73ddabdd 100644 --- a/third_party/mkl/build_defs.bzl +++ b/third_party/mkl/build_defs.bzl @@ -20,7 +20,7 @@ def if_mkl(if_true, if_false = []): """ return select({ - "//third_party/mkl:using_mkl": if_true, + str(Label("//third_party/mkl:using_mkl")): if_true, "//conditions:default": if_false }) diff --git a/third_party/nccl.BUILD b/third_party/nccl.BUILD index 3a2a3afe46..b2b8e18824 100644 --- a/third_party/nccl.BUILD +++ b/third_party/nccl.BUILD @@ -55,7 +55,7 @@ cc_library( ], "@org_tensorflow//tensorflow:ios": [], "@org_tensorflow//tensorflow:windows": [ - "ws2_32.lib", + "-DEFAULTLIB:ws2_32.lib", ], "//conditions:default": [ "-lrt", diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index bbc07905fc..c16eb3a12a 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -1,11 +1,8 @@ -# -*- Python -*- """Repository rule for Python autoconfiguration. `python_configure` depends on the following environment variables: - * `NUMPY_INCLUDE_PATH`: Location of Numpy libraries. * `PYTHON_BIN_PATH`: location of python binary. - * `PYTHON_INCLUDE_PATH`: Location of python binaries. * `PYTHON_LIB_PATH`: Location of python libraries. """ @@ -23,32 +20,13 @@ def _tpl(repository_ctx, tpl, substitutions={}, out=None): substitutions) -def _python_configure_warning(msg): - """Output warning message during auto configuration.""" - yellow = "\033[1;33m" - no_color = "\033[0m" - print("%sPython Configuration Warning:%s %s" % (yellow, no_color, msg)) - - -def _python_configure_fail(msg): +def _fail(msg): """Output failure message when auto configuration fails.""" red = "\033[0;31m" no_color = "\033[0m" fail("%sPython Configuration Error:%s %s\n" % (red, no_color, msg)) -def _get_env_var(repository_ctx, name, default = None, enable_warning = True): - """Find an environment variable in system path.""" - if name in repository_ctx.os.environ: - return repository_ctx.os.environ[name] - if default != None: - if enable_warning: - _python_configure_warning( - "'%s' environment variable is not set, using '%s' as default" % (name, default)) - return default - _python_configure_fail("'%s' environment variable is not set" % name) - - def _is_windows(repository_ctx): """Returns true if the host operating system is windows.""" os_name = repository_ctx.os.name.lower() @@ -73,11 +51,10 @@ def _execute(repository_ctx, cmdline, error_msg=None, error_details=None, """ result = repository_ctx.execute(cmdline) if result.stderr or not (empty_stdout_fine or result.stdout): - _python_configure_fail( - "\n".join([ - error_msg.strip() if error_msg else "Repository command failed", - result.stderr.strip(), - error_details if error_details else ""])) + _fail("\n".join([ + error_msg.strip() if error_msg else "Repository command failed", + result.stderr.strip(), + error_details if error_details else ""])) return result @@ -163,21 +140,23 @@ def _symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name, def _get_python_bin(repository_ctx): """Gets the python bin path.""" - python_bin = _get_env_var(repository_ctx, _PYTHON_BIN_PATH, - None, False) + 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) - path = _get_env_var(repository_ctx, "PATH") - _python_configure_fail("Cannot find python in PATH, please make sure " + - "python is installed and add its directory in PATH, or set the " + - "environment variable PYTHON_BIN_PATH.\nPATH=%s" % (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 _get_python_lib(repository_ctx, python_bin): """Gets the python lib path.""" + python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH) + if python_lib != None: + return python_lib print_lib = ("<<END\n" + "from __future__ import print_function\n" + "import site\n" + @@ -214,7 +193,7 @@ def _check_python_lib(repository_ctx, python_lib): cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib) result = repository_ctx.execute(["bash", "-c", cmd]) if result.return_code == 1: - _python_configure_fail("Invalid python library path: %s" % python_lib) + _fail("Invalid python library path: %s" % python_lib) def _check_python_bin(repository_ctx, python_bin): @@ -222,33 +201,36 @@ def _check_python_bin(repository_ctx, python_bin): cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin) result = repository_ctx.execute(["bash", "-c", cmd]) if result.return_code == 1: - _python_configure_fail( - "PYTHON_BIN_PATH is not executable. Is it the python binary?") + _fail("--define %s='%s' is not executable. Is it the python binary?" % ( + _PYTHON_BIN_PATH, python_bin)) def _get_python_include(repository_ctx, python_bin): """Gets the python include path.""" - result = _execute(repository_ctx, - [python_bin, "-c", - 'from __future__ import print_function;' + - 'from distutils import sysconfig;' + - 'print(sysconfig.get_python_inc())'], - error_msg="Problem getting python include path.", - error_details=("Is the Python binary path set up right? " + - "(See ./configure or PYTHON_BIN_PATH.) " + - "Is distutils installed?")) + result = _execute( + repository_ctx, + [python_bin, "-c", + 'from __future__ import print_function;' + + 'from distutils import sysconfig;' + + 'print(sysconfig.get_python_inc())'], + error_msg="Problem getting python include path.", + error_details=("Is the Python binary path set up right? " + + "(See ./configure or " + _PYTHON_BIN_PATH + ".) " + + "Is distutils installed?")) return result.stdout.splitlines()[0] def _get_python_import_lib_name(repository_ctx, python_bin): """Get Python import library name (pythonXY.lib) on Windows.""" - result = _execute(repository_ctx, - [python_bin, "-c", - 'import sys;' + - 'print("python" + str(sys.version_info[0]) + str(sys.version_info[1]) + ".lib")'], - error_msg="Problem getting python import library.", - error_details=("Is the Python binary path set up right? " + - "(See ./configure or PYTHON_BIN_PATH.) ")) + result = _execute( + repository_ctx, + [python_bin, "-c", + 'import sys;' + + 'print("python" + str(sys.version_info[0]) + ' + + ' str(sys.version_info[1]) + ".lib")'], + error_msg="Problem getting python import library.", + error_details=("Is the Python binary path set up right? " + + "(See ./configure or " + _PYTHON_BIN_PATH + ".) ")) return result.stdout.splitlines()[0] @@ -267,8 +249,7 @@ def _create_local_python_repository(repository_ctx): """Creates the repository containing files set up to build with Python.""" python_bin = _get_python_bin(repository_ctx) _check_python_bin(repository_ctx, python_bin) - python_lib = _get_env_var(repository_ctx, _PYTHON_LIB_PATH, - _get_python_lib(repository_ctx, python_bin)) + python_lib = _get_python_lib(repository_ctx, python_bin) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) numpy_include = _get_numpy_include(repository_ctx, python_bin) + '/numpy' |