1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Drop Python2 support.

This commit is contained in:
Alexander Smorkalov
2023-07-13 16:07:10 +03:00
parent cea26341a5
commit 1a3523d2d8
51 changed files with 65 additions and 344 deletions
-10
View File
@@ -4,13 +4,9 @@
if(DEFINED OPENCV_INITIAL_PASS) # OpenCV build
if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
ocv_module_disable_(python2)
ocv_module_disable_(python3)
return()
elseif(BUILD_opencv_world OR (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug"))
if(NOT DEFINED BUILD_opencv_python2)
set(__disable_python2 ON)
endif()
if(NOT DEFINED BUILD_opencv_python3)
set(__disable_python3 ON)
endif()
@@ -20,17 +16,11 @@ add_subdirectory(bindings)
add_subdirectory(test)
if(__disable_python2)
ocv_module_disable_(python2)
endif()
if(__disable_python3)
ocv_module_disable_(python3)
endif()
if(__disable_python2 AND __disable_python3)
return()
endif()
add_subdirectory(python2)
add_subdirectory(python3)
else() # standalone build
-15
View File
@@ -1,15 +0,0 @@
if(NOT PYTHON2_INCLUDE_PATH OR NOT PYTHON2_NUMPY_INCLUDE_DIRS)
ocv_module_disable(python2)
endif()
set(the_description "The python2 bindings")
set(MODULE_NAME python2)
# Buildbot requires Python 2 to be in root lib dir
set(MODULE_INSTALL_SUBDIR "")
set(PYTHON PYTHON2)
include(../common.cmake)
unset(MODULE_NAME)
unset(MODULE_INSTALL_SUBDIR)
-1
View File
@@ -42,7 +42,6 @@ sum::Size_MatType::(Y, X)
32FC1 0.05 ms 1.77 ms 5.23 ms 11.72 ms
"""
from __future__ import print_function
import testlog_parser, sys, os, xml, re
from table_formatter import *
from optparse import OptionParser
-1
View File
@@ -22,7 +22,6 @@ opencv Normalize::OCL_NormalizeFixture 5.412 96
... ... ... ...
"""
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
-1
View File
@@ -34,7 +34,6 @@ RadiusMatch::OCL_BruteForceMatcherFixture::(640x480, 32FC1) 1372.68 ms 1375.52 m
--show-all - also include empty and "notrun" lines
"""
from __future__ import print_function
import testlog_parser, sys, os, xml, re, glob
from table_formatter import *
from optparse import OptionParser
-1
View File
@@ -2,7 +2,6 @@
""" Utility package for run.py
"""
from __future__ import print_function
import xml.etree.ElementTree as ET
from glob import glob
from pprint import PrettyPrinter as PP
+3 -3
View File
@@ -73,7 +73,7 @@ class TestSuite(object):
return set(res)
def isTest(self, fullpath):
if fullpath in ['java', 'python2', 'python3']:
if fullpath in ['java', 'python3']:
return self.options.mode == 'test'
if not os.path.isfile(fullpath):
return False
@@ -123,7 +123,7 @@ class TestSuite(object):
cmd += ["buildAndTest"]
ret = execute(cmd, cwd=self.cache.java_test_dir)
return None, ret
elif module in ['python2', 'python3']:
elif module == 'python3':
executable = os.getenv('OPENCV_PYTHON_BINARY', None)
if executable is None or module == 'python{}'.format(sys.version_info[0]):
executable = sys.executable
@@ -181,7 +181,7 @@ class TestSuite(object):
more_args = []
exe = self.getTest(test)
if exe in ["java", "python2", "python3"]:
if exe in ["java", "python3"]:
logname = None
else:
userlog = [a for a in args if a.startswith("--gtest_output=")]
+1 -7
View File
@@ -92,7 +92,6 @@ parse_patterns = (
{'name': "java_test_dir", 'default': None, 'pattern': re.compile(r"^OPENCV_JAVA_TEST_DIR:\w+=(.*)$")},
{'name': "is_x64", 'default': "OFF", 'pattern': re.compile(r"^CUDA_64_BIT_DEVICE_CODE:\w+=(ON)$")},
{'name': "cmake_generator", 'default': None, 'pattern': re.compile(r"^CMAKE_GENERATOR:\w+=(.+)$")},
{'name': "python2", 'default': None, 'pattern': re.compile(r"^BUILD_opencv_python2:\w+=(.*)$")},
{'name': "python3", 'default': None, 'pattern': re.compile(r"^BUILD_opencv_python3:\w+=(.*)$")},
)
@@ -153,22 +152,17 @@ class CMakeCache:
files = glob.glob(os.path.join(d, mask))
if not self.getOS() == "android" and self.withJava():
files.append("java")
if self.withPython2():
files.append("python2")
if self.withPython3():
files.append("python3")
return [f for f in files if isGood(f)]
return []
def isMainModule(self, name):
return name in self.main_modules + ['python2', 'python3']
return name in self.main_modules + ['python3']
def withJava(self):
return self.ant_executable and self.java_test_dir and os.path.exists(self.java_test_dir)
def withPython2(self):
return self.python2 == 'ON'
def withPython3(self):
return self.python3 == 'ON'
-1
View File
@@ -32,7 +32,6 @@ LUT::OCL_LUTFixture::(640x480, 32FC4) 21.254 4.296 4.95
LUT::SizePrm::640x480 2.268 0.687 3.30
"""
from __future__ import print_function
import testlog_parser, sys, os, xml, glob, re
from table_formatter import *
from optparse import OptionParser
+1 -9
View File
@@ -4,12 +4,8 @@
This module serves as utility for other scripts.
"""
from __future__ import print_function
import sys, re, os.path, stat, math
try:
from html import escape
except ImportError:
from cgi import escape # Python 2.7
from html import escape
from optparse import OptionParser
from color import getColorizer, dummyColorizer
@@ -215,12 +211,8 @@ class table(object):
cell.width = len(max(cell.text, key = lambda line: len(line)))
def reformatTextValue(self, value):
if sys.version_info >= (2,7):
unicode = str
if isinstance(value, str):
vstr = value
elif isinstance(value, unicode):
vstr = str(value)
else:
try:
vstr = '\n'.join([str(v) for v in value])
+5 -8
View File
@@ -3,16 +3,13 @@
This module serves as utility for other scripts.
"""
from __future__ import print_function
import collections
import re
import os.path
import sys
from xml.dom.minidom import parse
if sys.version_info > (3,):
long = int
def cmp(a, b): return (a>b)-(a<b)
def cmp(a, b): return (a>b)-(a<b)
class TestInfo(object):
@@ -59,9 +56,9 @@ class TestInfo(object):
def parseLongMetric(self, xmlnode, name, default = 0):
if name in self.properties:
self.metrix[name] = long(self.properties[name])
self.metrix[name] = int(self.properties[name])
elif xmlnode.hasAttribute(name):
self.metrix[name] = long(xmlnode.getAttribute(name))
self.metrix[name] = int(xmlnode.getAttribute(name))
else:
self.metrix[name] = default
@@ -117,8 +114,8 @@ class TestInfo(object):
if units == "ns":
scale = 1000000000.0
if units == "ticks":
frequency = long(1)
scale = long(1)
frequency = int(1)
scale = int(1)
return val * scale / frequency
return val
-12
View File
@@ -26,19 +26,12 @@ See https://github.com/opencv/opencv/wiki/Profiling-OpenCV-Applications for more
0.173 ...
"""
from __future__ import print_function
import os
import sys
import csv
from pprint import pprint
from collections import deque
try:
long # Python 2
except NameError:
long = int # Python 3
# trace.hpp
REGION_FLAG_IMPL_MASK = 15 << 16
REGION_FLAG_IMPL_IPP = 1 << 16
@@ -65,11 +58,6 @@ def tryNum(s):
return int(s)
except ValueError:
pass
if sys.version_info[0] < 3:
try:
return long(s)
except ValueError:
pass
return s
def formatTimestamp(t):
-2
View File
@@ -74,8 +74,6 @@
Finally, run the script. Use the --help option for usage information.
"""
from __future__ import division
import ast
import errno
import fnmatch