use realpath in common.bzl; change from normpath to realpath

apply @byronyi's suggestions
This commit is contained in:
Jinzhe Zeng 2020-02-24 15:12:41 -05:00
parent a836864711
commit d6391e9c25
2 changed files with 5 additions and 4 deletions

View File

@ -50,6 +50,7 @@ load(
"raw_exec", "raw_exec",
"read_dir", "read_dir",
"which", "which",
"realpath",
) )
_GCC_HOST_COMPILER_PATH = "GCC_HOST_COMPILER_PATH" _GCC_HOST_COMPILER_PATH = "GCC_HOST_COMPILER_PATH"
@ -360,8 +361,8 @@ def _cuda_include_path(repository_ctx, cuda_config):
) )
inc_entries = [] inc_entries = []
if target_dir != "": if target_dir != "":
inc_entries.append(str(repository_ctx.path(target_dir).realpath)) inc_entries.append(realpath(repository_ctx, target_dir))
inc_entries.append(str(repository_ctx.path(cuda_config.cuda_toolkit_path + "/include").realpath)) inc_entries.append(realpath(repository_ctx, cuda_config.cuda_toolkit_path + "/include"))
return inc_entries return inc_entries
def enable_cuda(repository_ctx): def enable_cuda(repository_ctx):

View File

@ -437,7 +437,7 @@ def _get_legacy_path(env_name, default=[]):
def _normalize_path(path): def _normalize_path(path):
"""Returns normalized path, with forward slashes on Windows.""" """Returns normalized path, with forward slashes on Windows."""
path = os.path.normpath(path) path = os.path.realpath(path)
if _is_windows(): if _is_windows():
path = path.replace("\\", "/") path = path.replace("\\", "/")
return path return path
@ -449,7 +449,7 @@ def find_cuda_config():
cuda_version = os.environ.get("TF_CUDA_VERSION", "") cuda_version = os.environ.get("TF_CUDA_VERSION", "")
base_paths = _list_from_env("TF_CUDA_PATHS", base_paths = _list_from_env("TF_CUDA_PATHS",
_get_default_cuda_paths(cuda_version)) _get_default_cuda_paths(cuda_version))
base_paths = [os.path.realpath(path) for path in base_paths if os.path.exists(path)] base_paths = [path for path in base_paths if os.path.exists(path)]
result = {} result = {}
if "cuda" in libraries: if "cuda" in libraries: