From 12f103aaa2cac504484a475efea9e2cb973203c6 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Wed, 7 Jul 2021 09:59:45 +0800 Subject: [PATCH] [Cherry-Pick 33556]del python2 code (#33987) * del python2 code * cherry-pick 33556 --- CMakeLists.txt | 2 +- python/requirements.txt | 3 +-- python/unittest_py/requirements.txt | 6 ++---- tools/count_api_without_core_ops.py | 5 +---- tools/print_signatures.py | 7 ++----- tools/sampcd_processor.py | 2 +- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edb9a46c03a..a4357f5d155 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,7 +209,7 @@ option(WITH_STRIP "Strip so files of Whl packages" OFF) # PY_VERSION if(NOT PY_VERSION) - set(PY_VERSION 2.7) + set(PY_VERSION 3.6) endif() set(PYBIND11_PYTHON_VERSION ${PY_VERSION}) diff --git a/python/requirements.txt b/python/requirements.txt index 14bd5e7caa6..e9da2aa24d6 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,5 +1,4 @@ requests>=2.20.0 -numpy>=1.13, <=1.16.4 ; python_version<"3.5" numpy>=1.13 ; python_version>="3.5" and platform_system != "Windows" numpy>=1.13, <=1.19.3 ; python_version>="3.5" and platform_system == "Windows" protobuf>=3.1.0 @@ -7,5 +6,5 @@ gast>=0.3.3, <=0.4.0 ; platform_system != "Windows" gast==0.3.3 ; platform_system == "Windows" Pillow six -decorator==4.4.2 +decorator astor diff --git a/python/unittest_py/requirements.txt b/python/unittest_py/requirements.txt index 752f3545c69..8fd1be69a3d 100644 --- a/python/unittest_py/requirements.txt +++ b/python/unittest_py/requirements.txt @@ -4,10 +4,8 @@ pycrypto ; platform_system != "Windows" mock gym opencv-python<=4.2.0.32 -visualdl ; python_version>="3.5" +visualdl paddle2onnx>=0.4 -scipy>=0.19.0, <=1.2.1 ; python_version<"3.5" -scipy<=1.3.1 ; python_version=="3.5" -scipy ; python_version>"3.5" +scipy prettytable distro diff --git a/tools/count_api_without_core_ops.py b/tools/count_api_without_core_ops.py index 664b94a059f..7af597600e0 100644 --- a/tools/count_api_without_core_ops.py +++ b/tools/count_api_without_core_ops.py @@ -37,10 +37,7 @@ omitted_list = [ def md5(doc): try: hashinst = hashlib.md5() - if platform.python_version()[0] == "2": - hashinst.update(str(doc)) - else: - hashinst.update(str(doc).encode('utf-8')) + hashinst.update(str(doc).encode('utf-8')) md5sum = hashinst.hexdigest() except UnicodeDecodeError as e: md5sum = None diff --git a/tools/print_signatures.py b/tools/print_signatures.py index 6de9d84379f..be32ef09b70 100644 --- a/tools/print_signatures.py +++ b/tools/print_signatures.py @@ -36,10 +36,7 @@ visited_modules = set() def md5(doc): try: hashinst = hashlib.md5() - if platform.python_version()[0] == "2": - hashinst.update(str(doc)) - else: - hashinst.update(str(doc).encode('utf-8')) + hashinst.update(str(doc).encode('utf-8')) md5sum = hashinst.hexdigest() except UnicodeDecodeError as e: md5sum = None @@ -142,7 +139,7 @@ def visit_member(parent_name, member, member_name=None): def is_primitive(instance): - int_types = (int, long) if platform.python_version()[0] == "2" else (int, ) + int_types = (int, ) pritimitive_types = int_types + (float, str) if isinstance(instance, pritimitive_types): return True diff --git a/tools/sampcd_processor.py b/tools/sampcd_processor.py index a1658e3c2ed..f243ada0736 100644 --- a/tools/sampcd_processor.py +++ b/tools/sampcd_processor.py @@ -389,7 +389,7 @@ def execute_samplecode(tfname): """ result = True msg = None - if platform.python_version()[0] in ["2", "3"]: + if platform.python_version()[0] in ["3"]: cmd = [sys.executable, tfname] else: logger.error("Error: fail to parse python version!") -- GitLab