From 5644c92962ab44a3a756c377e121b49ebaf1fa31 Mon Sep 17 00:00:00 2001 From: Torsten Kilias Date: Fri, 10 Mar 2023 10:20:02 +0100 Subject: [PATCH] #764: Remove Python 2 from standard flavor 7.x (#348) * Remove python2 from build scripts * Remove python2 from the python implementation of the udfclient --------- Co-authored-by: Thomas Ubensee <34603111+tomuben@users.noreply.github.com> --- exaudfclient/base/.bazelrc | 8 -- exaudfclient/base/BUILD | 56 ----------- exaudfclient/base/WORKSPACE | 2 - .../python/exascript_python_preset_core.py | 15 +-- .../base/python/exascript_python_wrap.py | 34 +++---- .../extend_exascript_python_preset_py.sh | 9 +- exaudfclient/base/python/python2/BUILD | 97 ------------------- exaudfclient/base/python/pythoncontainer.cc | 42 +------- exaudfclient/base/python_repository.bzl | 26 ++--- .../base_test_deps/packages/apt_get_packages | 2 - .../base_test_deps/packages/apt_get_packages | 1 - 11 files changed, 37 insertions(+), 255 deletions(-) delete mode 100644 exaudfclient/base/python/python2/BUILD diff --git a/exaudfclient/base/.bazelrc b/exaudfclient/base/.bazelrc index e84cf4712..82c7b4a49 100644 --- a/exaudfclient/base/.bazelrc +++ b/exaudfclient/base/.bazelrc @@ -3,18 +3,10 @@ build --copt='-std=c++14' --force_pic --action_env=PROTOBUF_BIN --action_env=PRO build:benchmark --define benchmark=true build:java --define java=true --action_env=JAVA_PREFIX build:python --define python=true --action_env=PYTHON2_SYSPATH --action_env=PYTHON2_PREFIX --action_env=PYTHON2_VERSION --action_env=NUMPY_PREFIX --action_env=PYTHON3_SYSPATH --action_env=PYTHON3_PREFIX --action_env=PYTHON3_VERSION -build:fast-binary-py2 --copt='-DCUSTOM_LIBEXAUDFLIB_PATH="/exaudf/libexaudflib_complete.so"' --define binary_type=fast_binary //:exaudfclient build:fast-binary-py3 --copt='-DCUSTOM_LIBEXAUDFLIB_PATH="/exaudf/libexaudflib_complete.so"' --define binary_type=fast_binary //:exaudfclient_py3 -build:fast-binary-both --config=fast-binary-py2 --config=fast-binary-py3 -build:slow-wrapper-py2 --define binary_type=slow_wrapper //:exaudfclient build:slow-wrapper-py3 --define binary_type=slow_wrapper //:exaudfclient_py3 -build:slow-wrapper-both --config=slow-wrapper-py2 --config=slow-wrapper-py3 build:static-binary-py3 //:exaudfclient_py3_static -build:static-binary-py2 //:exaudfclient_py2_static -build:static-binary-both --config=static-binary-py3 --config=static-binary-py2 build:test-binaries-py3 --config=static-binary-py3 --config=slow-wrapper-py3 -build:test-binaries-py2 --config=static-binary-py2 --config=slow-wrapper-py2 -build:test-binaries-both --config=test-binaries-py2 --config=test-binaries-py3 build:verbose --copt='-v' --subcommands --verbose_failures --announce_rc #TODO test linkopts="-flto" build:optimize --copt="-g0" --copt="-DNDEBUG" --copt=-fstack-protector-strong --copt=-fomit-frame-pointer --copt=-ffunction-sections --copt=-fdata-sections --copt="-O3" --copt="-U_FORTIFY_SOURCE" --copt="-flto" --copt="-fuse-linker-plugin" diff --git a/exaudfclient/base/BUILD b/exaudfclient/base/BUILD index e8df81539..4d9daa704 100644 --- a/exaudfclient/base/BUILD +++ b/exaudfclient/base/BUILD @@ -94,26 +94,11 @@ VM_ENABLED_DEPS=select({ "//conditions:default": [] }) -VM_PYTHON2_DEPS=select({ - ":python": ["//python/python2:pythoncontainer"], - "//conditions:default": [] - }) - VM_PYTHON3_DEPS=select({ ":python": ["//python/python3:pythoncontainer"], "//conditions:default": [] }) -cc_binary( - name = "exaudfclient_bin", - srcs = ["exaudfclient.cc", "load_dynamic.cc"], - linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace - deps = ["//exaudflib:header", "//:debug_message_h"]+VM_ENABLED_DEPS+VM_PYTHON2_DEPS+ - ["//exaudflib:exaudflib-deps"], - defines = VM_ENABLED_DEFINES, - data = [":libexaudflib_complete.so"], -) - cc_binary( name = "exaudfclient_py3_bin", srcs = ["exaudfclient.cc", "load_dynamic.cc"], @@ -137,16 +122,6 @@ cc_binary( ## and hence does not contain dependency information. We cannot declare the shared lib (:exaudflib_complete.so) ## as dependency as it is a binary for bazel. -cc_binary( - name = "exaudfclient_py2_static_bin", - srcs = ["exaudfclient.cc", "load_dynamic.cc"], - linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace - deps = ["//exaudflib:header", "//:debug_message_h"]+VM_ENABLED_DEPS+VM_PYTHON2_DEPS+ - ["//exaudflib:exaudflib-deps"] + [ "@zmq//:zmq", "@protobuf//:protobuf"], - defines = VM_ENABLED_DEFINES, - data = [":libexaudflib_complete.so"], -) - cc_binary( name = "exaudfclient_py3_static_bin", srcs = ["exaudfclient.cc", "load_dynamic.cc"], @@ -175,21 +150,6 @@ sh_library( }) ) -SLOW_WRAPPER_BINARY_PY2="""$(location //:wrapper_generator_bin) "$(location exaudfclient_bin)" "$(location exaudfclient)" "$(location exaudfclient.template.sh)" """ -FAST_BINARY_PY2="""cp "$(location exaudfclient_bin)" "$(location exaudfclient)" """ -CREATE_BINARY_PY2_SCRIPT=select({ - "//:fast_binary": FAST_BINARY_PY2, - "//:slow_wrapper": SLOW_WRAPPER_BINARY_PY2, - "//conditions:default": FAST_BINARY_PY2 - }) -genrule( - name = "exaudfclient", - cmd = CREATE_BINARY_PY2_SCRIPT, - outs = ["exaudfclient"], - srcs = [":exaudfclient_bin", "//:libexaudflib_complete.so", "exaudfclient.template.sh","//:wrapper_generator_bin"], - output_to_bindir = True -) - SLOW_WRAPPER_BINARY_PY3="""$(location //:wrapper_generator_bin) "$(location exaudfclient_py3_bin)" "$(location exaudfclient_py3)" "$(location exaudfclient.template.sh)" """ FAST_BINARY_PY3="""cp "$(location exaudfclient_py3_bin)" "$(location exaudfclient_py3)" """ CREATE_BINARY_PY3_SCRIPT=select({ @@ -205,22 +165,6 @@ genrule( output_to_bindir = True ) -SLOW_WRAPPER_STATIC_BINARY_PY2="""$(location //:wrapper_generator_bin) "$(location exaudfclient_py2_static_bin)" "$(location exaudfclient_py2_static)" "$(location exaudfclient.template.sh)" """ -FAST_BINARY_STATIC_PY2="""cp "$(location exaudfclient_py2_static_bin)" "$(location exaudfclient_py2_static)" """ -CREATE_STATIC_BINARY_PY2_SCRIPT=select({ - "//:fast_binary": FAST_BINARY_STATIC_PY2, - "//:slow_wrapper": SLOW_WRAPPER_STATIC_BINARY_PY2, - "//conditions:default": FAST_BINARY_STATIC_PY2 - }) - -genrule( - name = "exaudfclient_py2_static", - cmd = CREATE_STATIC_BINARY_PY2_SCRIPT, - outs = ["exaudfclient_py2_static"], - srcs = [":exaudfclient_py2_static_bin", "//:libexaudflib_complete.so", "exaudfclient.template.sh", "//:wrapper_generator_bin"], - output_to_bindir = True -) - SLOW_WRAPPER_STATIC_BINARY_PY3="""$(location //:wrapper_generator_bin) "$(location exaudfclient_py3_static_bin)" "$(location exaudfclient_py3_static)" "$(location exaudfclient.template.sh)" """ FAST_BINARY_STATIC_PY3="""cp "$(location exaudfclient_py3_static_bin)" "$(location exaudfclient_py3_static)" """ CREATE_STATIC_BINARY_PY3_SCRIPT=select({ diff --git a/exaudfclient/base/WORKSPACE b/exaudfclient/base/WORKSPACE index ce883e405..dc77c672f 100644 --- a/exaudfclient/base/WORKSPACE +++ b/exaudfclient/base/WORKSPACE @@ -13,8 +13,6 @@ load("//:python_repository.bzl", "python_local_repository") python_local_repository(name = "python3") -python_local_repository(name = "python2") - load("//:python_repository.bzl", "numpy_local_repository") numpy_local_repository(name = "numpy") diff --git a/exaudfclient/base/python/exascript_python_preset_core.py b/exaudfclient/base/python/exascript_python_preset_core.py index 2e4385dc0..550b31949 100644 --- a/exaudfclient/base/python/exascript_python_preset_core.py +++ b/exaudfclient/base/python/exascript_python_preset_core.py @@ -1,11 +1,7 @@ import sys -if sys.version_info[0] >= 3: - unicode = str - decodeUTF8 = lambda x: x - encodeUTF8 = lambda x: x -else: - decodeUTF8 = lambda x: x.decode('utf-8') - encodeUTF8 = lambda x: x.encode('utf-8') +unicode = str +decodeUTF8 = lambda x: x +encodeUTF8 = lambda x: x from exascript_python import * import decimal @@ -181,10 +177,7 @@ def close(self): self.s.close() def __pythonvm_wrapped_parse(env): try: - if sys.version_info[0] >= 3: - exec(compile(exa.meta.script_code, exa.meta.script_name, 'exec'), env) - else: - exec(compile(exa.meta.script_code, exa.meta.script_name, 'exec')) in globals() + exec(compile(exa.meta.script_code, exa.meta.script_name, 'exec'), env) except BaseException as err: raise create_exception_with_complete_backtrace( "F-UDF-CL-SL-PYTHON-1122", diff --git a/exaudfclient/base/python/exascript_python_wrap.py b/exaudfclient/base/python/exascript_python_wrap.py index 9120d19a4..f2d6b2da1 100644 --- a/exaudfclient/base/python/exascript_python_wrap.py +++ b/exaudfclient/base/python/exascript_python_wrap.py @@ -1,27 +1,20 @@ import sys import os -isPython3 = False pyextdataframe_pkg = None -if sys.version_info[0] == 3: - unicode = str - decodeUTF8 = lambda x: x - encodeUTF8 = lambda x: x - long = int - isPython3 = True -else: - decodeUTF8 = lambda x: x.decode('utf-8') - encodeUTF8 = lambda x: x.encode('utf-8') +unicode = str +decodeUTF8 = lambda x: x +encodeUTF8 = lambda x: x +long = int -if isPython3: - if 'LIBPYEXADATAFRAME_DIR' in os.environ: - path_to_pyexadataframe=os.environ['LIBPYEXADATAFRAME_DIR'] - #print("sys.path append",path_to_pyexadataframe) - sys.path.append(path_to_pyexadataframe) - else: - path_to_pyexadataframe="/exaudf/python/python3" - #print("sys.path append",path_to_pyexadataframe) - sys.path.append(path_to_pyexadataframe) +if 'LIBPYEXADATAFRAME_DIR' in os.environ: + path_to_pyexadataframe=os.environ['LIBPYEXADATAFRAME_DIR'] + #print("sys.path append",path_to_pyexadataframe) + sys.path.append(path_to_pyexadataframe) +else: + path_to_pyexadataframe="/exaudf/python/python3" + #print("sys.path append",path_to_pyexadataframe) + sys.path.append(path_to_pyexadataframe) @@ -164,9 +157,6 @@ def emit(self, *output): % (decodeUTF8(self.__meta.outputColumnName(k)), type_names.get(self.__outcoltypes[k], 'UNKONWN'), str(type(v)))) self.__out.setBoolean(k, bool(v)) elif type(v) in (str, unicode): -# vl = len(v) -# if not isPython3 and type(v) == unicode: v = v.encode('utf-8') -# if isPython3 or type(v) == unicode: v = v.encode('utf-8') v = encodeUTF8(v) vl = len(v) if self.__outcoltypes[k] != STRING: diff --git a/exaudfclient/base/python/extend_exascript_python_preset_py.sh b/exaudfclient/base/python/extend_exascript_python_preset_py.sh index 3f3724f57..0b8e8a8e8 100644 --- a/exaudfclient/base/python/extend_exascript_python_preset_py.sh +++ b/exaudfclient/base/python/extend_exascript_python_preset_py.sh @@ -7,12 +7,7 @@ PYTHON_PREFIX=$3 PYTHON_VERSION=$4 PYTHON_SYSPATH=$5 echo "import sys, os" > extension -if [ "$PYTHON_VERSION" == "2*" ] -then - CURRENT_SYSPATH=$("$PYTHON_PREFIX/bin/$PYTHON_VERSION" -c 'import sys; import site; print sys.path') -else - CURRENT_SYSPATH=$("$PYTHON_PREFIX/bin/$PYTHON_VERSION" -c 'import sys; import site; print(sys.path)') -fi +CURRENT_SYSPATH=$("$PYTHON_PREFIX/bin/$PYTHON_VERSION" -c 'import sys; import site; print(sys.path)') echo "PYTHON_CURRENT_SYSPATH=$CURRENT_SYSPATH" echo "sys.path.extend($CURRENT_SYSPATH)" >> extension @@ -20,4 +15,4 @@ if [ ! "X$PYTHON_SYSPATH" = "X" ]; then echo "PYTHON_SYSPATH=$PYTHON_SYSPATH" echo "sys.path.extend($PYTHON_SYSPATH)" >> extension fi -cat extension "$INPUT" >> "$OUTPUT" \ No newline at end of file +cat extension "$INPUT" >> "$OUTPUT" diff --git a/exaudfclient/base/python/python2/BUILD b/exaudfclient/base/python/python2/BUILD deleted file mode 100644 index 0e11e9950..000000000 --- a/exaudfclient/base/python/python2/BUILD +++ /dev/null @@ -1,97 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -genrule( - name = "exascript_python_tmp_cc", - cmd = """ - INCLUDES=`$$PYTHON2_PREFIX/bin/$$PYTHON2_VERSION-config --includes` - mkdir -p build_exascript_python_tmp_cc/exaudflib - cp "$(location //exaudflib:swig/script_data_transfer_objects_wrapper.h)" "$(location //exaudflib:exascript.i)" build_exascript_python_tmp_cc/exaudflib - cd build_exascript_python_tmp_cc - swig -v $$INCLUDES -O -DEXTERNAL_PROCESS -Wall -c++ -python -addextern -module exascript_python -o "../$(location exascript_python_tmp.cc)" exaudflib/exascript.i - """, - outs = ["exascript_python_tmp.cc", "exascript_python.py"], - srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h"] -) - -genrule( - name = "exascript_python_tmp_h", - cmd = """ - INCLUDES=`$$PYTHON2_PREFIX/bin/$$PYTHON2_VERSION-config --includes` - mkdir build_exascript_python_tmp_h - cp "$(location //exaudflib:swig/script_data_transfer_objects_wrapper.h)" "$(location //exaudflib:exascript.i)" build_exascript_python_tmp_h - cp "$(location exascript_python_tmp.cc)" "$(location exascript_python.py)" build_exascript_python_tmp_h - cd build_exascript_python_tmp_h - swig -v $$INCLUDES -DEXTERNAL_PROCESS -c++ -python -external-runtime "../$(location exascript_python_tmp.h)" - """, - outs = ["exascript_python_tmp.h"], - srcs = ["//exaudflib:exascript.i","//exaudflib:swig/script_data_transfer_objects_wrapper.h", ":exascript_python_tmp.cc", "exascript_python.py"] -) - -genrule( - name = "extend_exascript_python_preset_py", - cmd = 'bash $(location //python:extend_exascript_python_preset_py.sh) "$(location //python:exascript_python_preset_core.py)" "$(location exascript_python_preset.py)" "$$PYTHON2_PREFIX" "$$PYTHON2_VERSION" ""', - outs = ["exascript_python_preset.py"], - srcs = ["//python:exascript_python_preset_core.py"], - tools = ["//python:extend_exascript_python_preset_py.sh"] -) - -genrule( - name = "exascript_python_int", - cmd = """ - cp $(SRCS) . - python3 $(location //:build_integrated.py) "$(location exascript_python_int.h)" "exascript_python.py" "exascript_python_wrap.py" "exascript_python_preset.py" - """, - outs = ["exascript_python_int.h"], - srcs = [":exascript_python_tmp_cc", "//python:exascript_python_wrap.py", ":extend_exascript_python_preset_py"], - tools = ["//:build_integrated.py"] -) - -genrule( - name = "filter_swig_code_exascript_python_h", - cmd = """ - ACTUAL_PYTHON_VERSION=`$$PYTHON2_PREFIX/bin/$$PYTHON2_VERSION -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'` - if [[ $$ACTUAL_PYTHON_VERSION == 2* ]] ; then - python3 $(location //:filter_swig_code.py) "$@" "$<" - else - cp "$<" "$@" - fi - """, - outs = ["exascript_python.h"], - srcs = [":exascript_python_tmp_h"], - tools = ["//:filter_swig_code.py"] -) - -genrule( - name = "filter_swig_code_exascript_python_cc", - cmd = """ - ACTUAL_PYTHON_VERSION=`$$PYTHON2_PREFIX/bin/$$PYTHON2_VERSION -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'` - cp $(locations exascript_python_tmp_cc) . - if [[ $$ACTUAL_PYTHON_VERSION == 2* ]] ; then - python3 $(location //:filter_swig_code.py) "$@" exascript_python_tmp.cc - else - cp exascript_python_tmp.cc "$@" - fi - """, - outs = ["exascript_python.cc"], - srcs = [":exascript_python_tmp_cc"], - tools = ["//:filter_swig_code.py"] -) - -cc_library( - name = "exascript_python", - srcs = [":filter_swig_code_exascript_python_cc",":filter_swig_code_exascript_python_h"], - hdrs = [":filter_swig_code_exascript_python_h"], - deps = ["@python2//:python2","//exaudflib:exaudflib-deps","//exaudflib:header"], - alwayslink=True, -) - -cc_library( - name = "pythoncontainer", - srcs = ["//python:pythoncontainer.cc"], - data = [":extend_exascript_python_preset_py"], - hdrs = [":exascript_python_int", ":filter_swig_code_exascript_python_h"], - include_prefix = ".", - deps = ["@python2//:python2",":exascript_python","//exaudflib:header", - "//:debug_message_h","//exaudflib:scriptoptionlines", "//python:pythoncontainer_header"], - alwayslink=True, -) diff --git a/exaudfclient/base/python/pythoncontainer.cc b/exaudfclient/base/python/pythoncontainer.cc index 1459074d0..43c6265a6 100644 --- a/exaudfclient/base/python/pythoncontainer.cc +++ b/exaudfclient/base/python/pythoncontainer.cc @@ -23,11 +23,7 @@ using namespace SWIGVMContainers; using namespace std; -#ifdef ENABLE_PYTHON3 extern "C" PyObject* PyInit__exascript_python(void); -#else -extern "C" void init_exascript_python(void); -#endif static void check(const std::string& error_code) { @@ -41,15 +37,10 @@ static void check(const std::string& error_code) { // Get Exception name if (NULL != (pvc = PyObject_GetAttrString(pv, "__class__"))) { if (NULL != (pvcn = PyObject_GetAttrString(pvc, "__name__"))) { -#ifdef ENABLE_PYTHON3 PyObject* repr = PyObject_Str(pvcn); PyObject* p3str = PyUnicode_AsEncodedString(repr, "utf-8", "ignore"); const char *bytes = PyBytes_AS_STRING(p3str); pvcns = string(bytes) + string(": "); - -#else - pvcns = string(PyString_AS_STRING(pvcn)) + string(": "); -#endif Py_XDECREF(pvcn); } Py_XDECREF(pvc); @@ -57,14 +48,10 @@ static void check(const std::string& error_code) { string exception_string(""); -#ifdef ENABLE_PYTHON3 PyObject* repr = PyObject_Str(s); PyObject* p3str = PyUnicode_AsEncodedString(repr, "utf-8", "ignore"); const char *bytes = PyBytes_AS_STRING(p3str); exception_string = error_code+": "+pvcns + string(bytes); -#else - exception_string = error_code+": "+pvcns + PyString_AS_STRING(s); -#endif PythonVM::exception x(exception_string.c_str()); Py_XDECREF(s); PyErr_Clear(); @@ -172,9 +159,7 @@ PythonVMImpl::PythonVMImpl(bool checkOnly): m_checkOnly(checkOnly) if (!Py_IsInitialized()) { ::setlocale(LC_ALL, "en_US.utf8"); Py_NoSiteFlag = 1; -#ifdef ENABLE_PYTHON3 PyImport_AppendInittab("_exascript_python",PyInit__exascript_python); -#endif Py_Initialize(); PyEval_InitThreads(); #ifndef DISABLE_PYTHON_SUBINTERP @@ -205,11 +190,6 @@ PythonVMImpl::PythonVMImpl(bool checkOnly): m_checkOnly(checkOnly) PythonThreadBlock block; PyThreadState_Swap(pythread); #endif - - -#ifndef ENABLE_PYTHON3 - init_exascript_python(); -#endif code = Py_CompileString(integrated_exascript_python_py, "exascript_python.py", Py_file_input); check("F-UDF-CL-SL-PYTHON-1008"); if (code == NULL) throw PythonVM::exception("F-UDF-CL-SL-PYTHON-1009: Failed to compile internal module"); exatable = PyImport_ExecCodeModule((char*)"exascript_python", code); @@ -219,11 +199,7 @@ PythonVMImpl::PythonVMImpl(bool checkOnly): m_checkOnly(checkOnly) code = Py_CompileString(integrated_exascript_python_preset_py, "", Py_file_input); check("F-UDF-CL-SL-PYTHON-1012"); if (code == NULL) {check("F-UDF-CL-SL-PYTHON-1013");} - #ifdef ENABLE_PYTHON3 PyEval_EvalCode(code, globals, globals); check("F-UDF-CL-SL-PYTHON-1014"); - #else - PyEval_EvalCode(reinterpret_cast(code), globals, globals); check("F-UDF-CL-SL-PYTHON-1015"); - #endif Py_DECREF(code); PyObject *runobj = PyDict_GetItemString(globals, "__pythonvm_wrapped_parse"); check("F-UDF-CL-SL-PYTHON-1016"); @@ -234,12 +210,7 @@ PythonVMImpl::PythonVMImpl(bool checkOnly): m_checkOnly(checkOnly) code = Py_CompileString(integrated_exascript_python_wrap_py, "", Py_file_input); check("F-UDF-CL-SL-PYTHON-1018"); if (code == NULL) throw PythonVM::exception("Failed to compile wrapping script"); -#ifdef ENABLE_PYTHON3 PyEval_EvalCode(code, globals, globals); check("F-UDF-CL-SL-PYTHON-1019"); -#else - PyEval_EvalCode(reinterpret_cast(code), globals, globals); check("F-UDF-CL-SL-PYTHON-1020"); -#endif - Py_XDECREF(code); } DBG_FUNC_END( cerr ); @@ -516,15 +487,10 @@ const char* PythonVMImpl::singleCall(single_call_function_id_e fn, const Executi throw PythonVM::exception(sb.str().c_str()); } -#ifdef ENABLE_PYTHON3 - PyObject* repr = PyObject_Str(retvalue); - PyObject* p3str = PyUnicode_AsEncodedString(repr, "utf-8", "ignore"); - const char *bytes = PyBytes_AS_STRING(p3str); - singleCallResult = string(bytes); -#else - const char * s = PyString_AsString(retvalue); - singleCallResult = string(s); -#endif + PyObject* repr = PyObject_Str(retvalue); + PyObject* p3str = PyUnicode_AsEncodedString(repr, "utf-8", "ignore"); + const char *bytes = PyBytes_AS_STRING(p3str); + singleCallResult = string(bytes); Py_XDECREF(retvalue); retvalue = NULL; return singleCallResult.c_str(); } diff --git a/exaudfclient/base/python_repository.bzl b/exaudfclient/base/python_repository.bzl index b1bed9c0f..b710c5b89 100644 --- a/exaudfclient/base/python_repository.bzl +++ b/exaudfclient/base/python_repository.bzl @@ -41,8 +41,10 @@ def _python_local_repository_impl(repository_ctx): python_version_env_var = repository_ctx.name.upper() + "_VERSION" if python_version_env_var in repository_ctx.os.environ: version = repository_ctx.os.environ[python_version_env_var] - if repository_ctx.name == "python3" and version.startswith("2") or repository_ctx.name == "python2" and version.startswith("3"): - fail("Wrong python version specified in environment variable %s, exppected %s, got %s"%(python_version_env_var,repository_ctx.name,version)) + if repository_ctx.name == "python3" and version.startswith("2"): + fail("Wrong python version specified in environment variable %s, got binary name '%s', but version number '%s'"%(python_version_env_var,repository_ctx.name,version)) + if repository_ctx.name == "python" or version.startswith("2"): + fail("Python 2 is not supported anymore, but specified in environment variable %s, got %s, %s"%(python_version_env_var,repository_ctx.name,version)) else: fail("Environment Variable %s not found"%python_version_env_var) print("python version in environment specified; %s"%version) @@ -52,11 +54,10 @@ def _python_local_repository_impl(repository_ctx): include_dir = _get_include_dir(binary, version, repository_ctx) lib_glob = _get_lib_glob(binary, version, repository_ctx) - - defines='"ENABLE_PYTHON_VM"' + defines = ['"ENABLE_PYTHON_VM"'] if actual_version[0]=="3": - defines = defines+',"ENABLE_PYTHON3"' - + defines.append('"ENABLE_PYTHON3"') + defines_str = ",".join(defines) build_file_content = """ cc_library( name = "{name}", @@ -65,7 +66,7 @@ cc_library( includes = ["{include_dir}"], defines = [{defines}], visibility = ["//visibility:public"] -)""".format(lib_glob=lib_glob[1:], include_dir=include_dir[1:], name=repository_ctx.name, defines=defines) +)""".format(lib_glob=lib_glob[1:], include_dir=include_dir[1:], name=repository_ctx.name, defines=defines_str) print(build_file_content) repository_ctx.symlink(prefix, "."+prefix) @@ -74,7 +75,7 @@ cc_library( python_local_repository = repository_rule( implementation=_python_local_repository_impl, local = True, - environ = ["PYTHON2_PREFIX","PYTHON3_PREFIX","PYTHON2_VERSION", "PYTHON3_VERSION"]) + environ = ["PYTHON3_PREFIX", "PYTHON3_VERSION"]) def _get_numpy_include_dir(binary,p_repository_ctx): @@ -100,14 +101,17 @@ def _numpy_local_repository_impl(repository_ctx): version = repository_ctx.os.environ[python_version_env_var] else: fail("Environment Variable %s not found"%python_version_env_var) + if version.startswith("2"): + fail("Wrong python version specified in environment variable %s, got binary name '%s', but version number '%s'"%(python_version_env_var,repository_ctx.name,version)) print("python version in environment specified; %s"%version) binary = prefix+"/bin/"+version actual_version = _get_actual_python_version(binary,repository_ctx) - defines='"ENABLE_PYTHON_VM"' + defines = ['"ENABLE_PYTHON_VM"'] if actual_version[0]=="3": - defines = defines+',"ENABLE_PYTHON3"' + defines.append('"ENABLE_PYTHON3"') + defines_str = ",".join(defines) numpy_include_dir =_get_numpy_include_dir(binary,repository_ctx) hdrs = numpy_include_dir + "/*/*.h" @@ -119,7 +123,7 @@ cc_library( includes = ["{includes}"], defines = [{defines}], visibility = ["//visibility:public"] -)""".format(hdrs=hdrs, includes=numpy_include_dir, name=repository_ctx.name, defines=defines) +)""".format(hdrs=hdrs, includes=numpy_include_dir, name=repository_ctx.name, defines=defines_str) print(build_file_content) repository_ctx.symlink(prefix, "."+prefix) diff --git a/flavors/python-3.7-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages b/flavors/python-3.7-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages index 61d5552e1..18b029c1c 100644 --- a/flavors/python-3.7-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages +++ b/flavors/python-3.7-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages @@ -1,5 +1,3 @@ -python-protobuf|3.0.0-9.1ubuntu1 -python-zmq|16.0.2-2build2 gdb|8.1.1-0ubuntu1 valgrind|1:3.13.0-2ubuntu2.3 gdbserver|8.1.1-0ubuntu1 diff --git a/flavors/python-3.8-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages b/flavors/python-3.8-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages index 738dbe79e..bce293264 100644 --- a/flavors/python-3.8-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages +++ b/flavors/python-3.8-minimal-EXASOL-6.2.0/flavor_base/base_test_deps/packages/apt_get_packages @@ -1,4 +1,3 @@ -python-protobuf|3.6.1.3-2ubuntu5 gdb|9.2-0ubuntu1~20.04.1 valgrind|1:3.15.0-1ubuntu9.1 gdbserver|9.2-0ubuntu1~20.04.1