From 8e0d6f12efec0aeef16a64c6422aa3e90bbf4058 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 21 Apr 2017 06:35:18 -0800 Subject: Automated rollback of change 153736477 Change: 153825726 --- util/python/BUILD | 28 ++-------------- util/python/python_config.sh | 76 +++----------------------------------------- 2 files changed, 7 insertions(+), 97 deletions(-) (limited to 'util') diff --git a/util/python/BUILD b/util/python/BUILD index 29688b875d..96daf9947a 100644 --- a/util/python/BUILD +++ b/util/python/BUILD @@ -2,31 +2,7 @@ licenses(["restricted"]) package(default_visibility = ["//visibility:public"]) -cc_library( +alias( name = "python_headers", - hdrs = glob([ - "python_include/**/*.h", - ]), - data = [":python_checked"], - includes = ["python_include"], -) - -genrule( - name = "python_check", - srcs = [ - "python_config.sh", - "configure_files", - ], - outs = [ - "python_checked", - ], - cmd = "OUTPUTDIR=\"$(@D)/\"; $(location :python_config.sh) --check && touch $$OUTPUTDIR/python_checked", - local = 1, -) - -filegroup( - name = "configure_files", - data = glob([ - "*", - ]), + actual = "@local_config_python//:python_headers", ) diff --git a/util/python/python_config.sh b/util/python/python_config.sh index 4b18bf3578..d5762ad456 100755 --- a/util/python/python_config.sh +++ b/util/python/python_config.sh @@ -26,23 +26,9 @@ else script_path=${script_path:-.} fi -EXPECTED_PATHS="$script_path/util/python/python_include"\ -" $script_path/util/python/python_lib"\ -" $script_path/third_party/py/numpy/numpy_include" - function main { - argument="$1" - shift - case $argument in - --check) - check_python - exit 0 - ;; - --setup) - setup_python "$1" - exit 0 - ;; - esac + setup_python "$1" + exit 0 } function python_path { @@ -93,6 +79,7 @@ END function setup_python { PYTHON_BIN_PATH="$1"; + # TODO(ngiraldo): move most of these checks to root configure if [ -z "$PYTHON_BIN_PATH" ]; then echo "PYTHON_BIN_PATH was not provided. Did you run configure?" exit 1 @@ -108,12 +95,7 @@ function setup_python { exit 1 fi - local python_include="$("${PYTHON_BIN_PATH}" -c 'from __future__ import print_function; from distutils import sysconfig; print(sysconfig.get_python_inc());')" - if [ "$python_include" == "" ]; then - echo -e "\n\nERROR: Problem getting python include path. Is distutils installed?" - exit 1 - fi - + # TODO(ngiraldo): confirm if these checks are really necessary, remove if not if [ -z "$PYTHON_LIB_PATH" ]; then local python_lib_path # Split python_path into an array of paths, this allows path containing spaces @@ -149,35 +131,12 @@ function setup_python { exit 1 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?" - exit 1 - fi - - for x in $EXPECTED_PATHS; do - if [ -e "$x" ]; then - rm -rf "$x" - fi - done - -# ln -sf is actually implemented as copying in msys since creating symbolic -# links is privileged on Windows. But copying is too slow, so invoke mklink -# to create junctions on Windows. - if is_windows; then - cmd /c "mklink /J util\\python\\python_include \"${python_include}\"" - cmd /c "mklink /J util\\python\\python_lib \"${python_lib}\"" - cmd /c "mklink /J third_party\\py\\numpy\\numpy_include \"${numpy_include}\"" - else - ln -sf "${python_include}" util/python/python_include - ln -sf "${python_lib}" util/python/python_lib - ln -sf "${numpy_include}" third_party/py/numpy/numpy_include - fi # Convert python path to Windows style before writing into bazel.rc if is_windows; then PYTHON_BIN_PATH="$(cygpath -m "$PYTHON_BIN_PATH")" fi + # TODO(ngiraldo): move all below to root configure # Write tools/bazel.rc echo "# Autogenerated by configure: DO NOT EDIT" > tools/bazel.rc sed -e "s/\$PYTHON_MAJOR_VERSION/$python_major_version/g" \ @@ -197,29 +156,4 @@ function is_windows() { fi } -function check_python { - for x in $EXPECTED_PATHS; do - if [ ! -e "$x" ]; then - echo -e "\n\nERROR: Cannot find '${x}'. Did you run configure?\n\n" 1>&2 - exit 1 - fi - # Don't check symbolic link on Windows - if ! is_windows && [ ! -L "${x}" ]; then - echo -e "\n\nERROR: '${x}' is not a symbolic link. Internal error.\n\n" 1>&2 - exit 1 - fi - if is_windows; then - # In msys, readlink doesn't work, because no symbolic link on - # Windows. readlink -f returns the real path of a junction. - true_path=$(readlink -f "${x}") - else - true_path=$(readlink "${x}") - fi - if [ ! -d "${true_path}" ]; then - echo -e "\n\nERROR: '${x}' does not refer to an existing directory: ${true_path}. Do you need to rerun configure?\n\n" 1>&2 - exit 1 - fi - done -} - main "$@" -- cgit v1.2.3