This repository has been archived by the owner on Mar 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
tensorboard-python-binary.patch
56 lines (53 loc) · 1.81 KB
/
tensorboard-python-binary.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
diff --git a/python/tensorboard/tensorboard b/python/tensorboard/tensorboard
index a47d51c..8a8b8ff 100755
--- a/python/tensorboard/tensorboard
+++ b/python/tensorboard/tensorboard
@@ -7,11 +7,15 @@ import shutil
import sys
import subprocess
import zipfile
+import site
# Return True if running on Windows
def IsWindows():
return os.name == 'nt'
+# get Python version
+PY3 = sys.version_info[0] == 3
+
def GetWindowsPathWithUNCPrefix(path):
"""
Adding UNC prefix after getting a normalized absolute Windows path,
@@ -57,7 +61,15 @@ def FindPythonBinary():
'Bazel does not support execution of Python interpreters via labels yet')
elif PYTHON_BINARY.startswith('/'):
# Case 2: Absolute path.
- return PYTHON_BINARY
+ if os.path.exists(PYTHON_BINARY):
+ # file exists
+ return PYTHON_BINARY
+ else:
+ # have to search. often occurs in travis-built wheel.
+ if PY3:
+ return SearchPath('python3')
+ else:
+ return SearchPath('python')
elif '/' in PYTHON_BINARY:
# Case 3: Path is relative to current working directory.
return os.path.join(os.getcwd(), PYTHON_BINARY)
@@ -78,6 +90,18 @@ def FindModuleSpace():
module_space = stub_filename + '.runfiles'
if os.path.isdir(module_space):
break
+ package_path = site.getsitepackages()
+ # In case this instance is a string
+ if not isinstance(package_path, list):
+ package_path= [package_path]
+ user_path = site.getusersitepackages()
+ if not isinstance(user_path, list):
+ user_path = [user_path]
+ package_path.extend(user_path)
+ for mod in package_path:
+ module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
+ if os.path.isdir(module_space):
+ return module_space
runfiles_pattern = "(.*\.runfiles)/.*"
if IsWindows():