Skip to content
Permalink
Browse files

fixes github issue tensorflow#2703 by asking user for a specific pyth…

…on path from a list of possible known locations

Change: 129778433
  • Loading branch information...
itsmeolivia authored and tensorflower-gardener committed Aug 9, 2016
1 parent a8c5801 commit 4959a1291045674a23793212cfe94d4804760f01
Showing with 64 additions and 5 deletions.
  1. +2 −1 tensorflow/tools/ci_build/builds/configured
  2. +62 −4 util/python/python_config.sh
@@ -47,7 +47,8 @@ else
fi

pushd "${CI_TENSORFLOW_SUBMODULE_PATH:-.}"
./configure
echo '' > test_input.txt
./configure < test_input.txt
popd

# Gather and print build information
@@ -45,6 +45,48 @@ function main {
esac
}

function python_path {
python - <<END
from __future__ import print_function
import site
import os
try:
input = raw_input
except NameError:
pass
python_paths = []
if os.getenv('PYTHONPATH') is not None:
python_paths = os.getenv('PYTHONPATH').split(':')
all_paths = set(python_paths + site.getsitepackages())
paths = []
for path in all_paths:
if os.path.isdir(path):
paths.append(path)
if len(paths) == 1:
print(paths[0])
ret_paths = ""
for path in paths:
ret_paths += path + " "
print(ret_paths)
END
}

function default_python_path {
PYTHON_ARG="$1" python - <<END
from __future__ import print_function
import os
default = os.getenv('PYTHON_ARG')
default = str(default)
print(default)
END
}

function setup_python {
PYTHON_BIN_PATH="$1";

@@ -68,11 +110,27 @@ function setup_python {
echo -e "\n\nERROR: Problem getting python include path. Is distutils installed?"
exit 1
fi
local python_lib=$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; from distutils import sysconfig; print(sysconfig.get_python_lib());')
if [ "$python_lib" == "" ]; then
echo -e "\n\nERROR: Problem getting python lib path. Is distutils installed?"
exit 1

local python_lib_path=$(python_path)
echo "Found possible Python library paths:"
for x in $python_lib_path; do
echo " $x"
done
set -- $python_lib_path
echo "Please input the desired Python library path to use. Default is ["$1"]"
read b
if [ "$b" == "" ]; then
python_lib="$(default_python_path $python_lib_path)"
echo $python_lib
else
if test -d $b -a -x $b; then
python_lib=$b
else
echo -e "\n\nERROR: The path you have entered does not exist."
exit 1
fi
fi

local numpy_include=$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; import numpy; print(numpy.get_include());')
if [ "$numpy_include" == "" ]; then
echo -e "\n\nERROR: Problem getting numpy include path. Is numpy installed?"

0 comments on commit 4959a12

Please sign in to comment.
You can’t perform that action at this time.