Skip to content

Commit 4959a12

Browse files
itsmeoliviatensorflower-gardener
authored andcommitted
fixes github issue tensorflow#2703 by asking user for a specific python path from a list of possible known locations
Change: 129778433
1 parent a8c5801 commit 4959a12

2 files changed

Lines changed: 64 additions & 5 deletions

File tree

tensorflow/tools/ci_build/builds/configured

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ else
4747
fi
4848

4949
pushd "${CI_TENSORFLOW_SUBMODULE_PATH:-.}"
50-
./configure
50+
echo '' > test_input.txt
51+
./configure < test_input.txt
5152
popd
5253

5354
# Gather and print build information

util/python/python_config.sh

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,48 @@ function main {
4545
esac
4646
}
4747

48+
function python_path {
49+
python - <<END
50+
from __future__ import print_function
51+
import site
52+
import os
53+
54+
try:
55+
input = raw_input
56+
except NameError:
57+
pass
58+
59+
python_paths = []
60+
if os.getenv('PYTHONPATH') is not None:
61+
python_paths = os.getenv('PYTHONPATH').split(':')
62+
63+
all_paths = set(python_paths + site.getsitepackages())
64+
65+
paths = []
66+
for path in all_paths:
67+
if os.path.isdir(path):
68+
paths.append(path)
69+
70+
if len(paths) == 1:
71+
print(paths[0])
72+
ret_paths = ""
73+
for path in paths:
74+
ret_paths += path + " "
75+
print(ret_paths)
76+
END
77+
}
78+
79+
function default_python_path {
80+
PYTHON_ARG="$1" python - <<END
81+
from __future__ import print_function
82+
import os
83+
84+
default = os.getenv('PYTHON_ARG')
85+
default = str(default)
86+
print(default)
87+
END
88+
}
89+
4890
function setup_python {
4991
PYTHON_BIN_PATH="$1";
5092

@@ -68,11 +110,27 @@ function setup_python {
68110
echo -e "\n\nERROR: Problem getting python include path. Is distutils installed?"
69111
exit 1
70112
fi
71-
local python_lib=$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; from distutils import sysconfig; print(sysconfig.get_python_lib());')
72-
if [ "$python_lib" == "" ]; then
73-
echo -e "\n\nERROR: Problem getting python lib path. Is distutils installed?"
74-
exit 1
113+
114+
local python_lib_path=$(python_path)
115+
echo "Found possible Python library paths:"
116+
for x in $python_lib_path; do
117+
echo " $x"
118+
done
119+
set -- $python_lib_path
120+
echo "Please input the desired Python library path to use. Default is ["$1"]"
121+
read b
122+
if [ "$b" == "" ]; then
123+
python_lib="$(default_python_path $python_lib_path)"
124+
echo $python_lib
125+
else
126+
if test -d $b -a -x $b; then
127+
python_lib=$b
128+
else
129+
echo -e "\n\nERROR: The path you have entered does not exist."
130+
exit 1
131+
fi
75132
fi
133+
76134
local numpy_include=$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; import numpy; print(numpy.get_include());')
77135
if [ "$numpy_include" == "" ]; then
78136
echo -e "\n\nERROR: Problem getting numpy include path. Is numpy installed?"

0 commit comments

Comments
 (0)