Skip to content

Commit

Permalink
#764: Remove Python 2 from standard flavor 7.x (#348)
Browse files Browse the repository at this point in the history
* Remove python2 from build scripts
* Remove python2 from the python implementation of the udfclient

---------

Co-authored-by: Thomas Ubensee <[email protected]>
  • Loading branch information
tkilias and tomuben authored Mar 10, 2023
1 parent f3c8574 commit 5644c92
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 255 deletions.
8 changes: 0 additions & 8 deletions exaudfclient/base/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
56 changes: 0 additions & 56 deletions exaudfclient/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand Down
2 changes: 0 additions & 2 deletions exaudfclient/base/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 4 additions & 11 deletions exaudfclient/base/python/exascript_python_preset_core.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
Expand Down
34 changes: 12 additions & 22 deletions exaudfclient/base/python/exascript_python_wrap.py
Original file line number Diff line number Diff line change
@@ -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)



Expand Down Expand Up @@ -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:
Expand Down
9 changes: 2 additions & 7 deletions exaudfclient/base/python/extend_exascript_python_preset_py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ 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
if [ ! "X$PYTHON_SYSPATH" = "X" ]; then
echo "PYTHON_SYSPATH=$PYTHON_SYSPATH"
echo "sys.path.extend($PYTHON_SYSPATH)" >> extension
fi
cat extension "$INPUT" >> "$OUTPUT"
cat extension "$INPUT" >> "$OUTPUT"
97 changes: 0 additions & 97 deletions exaudfclient/base/python/python2/BUILD

This file was deleted.

Loading

0 comments on commit 5644c92

Please sign in to comment.