@@ -22,13 +22,17 @@ class Err(Exception):
22
22
def __init__ (self , msg , * args ):
23
23
self .msg = msg % args
24
24
25
- def execute (cmd , silent = False , cwd = "." ):
25
+ def execute (cmd , silent = False , cwd = "." , env = None ):
26
26
try :
27
27
log .debug ("Run: %s" , cmd )
28
+ if env :
29
+ for k in env :
30
+ log .debug (" Environ: %s=%s" , k , env [k ])
31
+ env = os .environ .update (env )
28
32
if silent :
29
- return check_output (cmd , stderr = STDOUT , cwd = cwd ).decode ("latin-1" )
33
+ return check_output (cmd , stderr = STDOUT , cwd = cwd , env = env ).decode ("latin-1" )
30
34
else :
31
- return check_call (cmd , cwd = cwd )
35
+ return check_call (cmd , cwd = cwd , env = env )
32
36
except CalledProcessError as e :
33
37
if silent :
34
38
log .debug ("Process returned: %d" , e .returncode )
@@ -171,6 +175,9 @@ def testSIMD(compiler, cxx_flags, compiler_arg = None):
171
175
{'name' : "cuda_library" , 'default' : None , 'pattern' : re .compile (r"^CUDA_CUDA_LIBRARY:FILEPATH=(.+)$" )},
172
176
{'name' : "cuda_version" , 'default' : None , 'pattern' : re .compile (r"^CUDA_VERSION:STRING=(.+)$" )},
173
177
{'name' : "core_dependencies" , 'default' : None , 'pattern' : re .compile (r"^opencv_core_LIB_DEPENDS:STATIC=(.+)$" )},
178
+ {'name' : "python" , 'default' : None , 'pattern' : re .compile (r"^BUILD_opencv_python:BOOL=(.*)$" )},
179
+ {'name' : "python2" , 'default' : None , 'pattern' : re .compile (r"^BUILD_opencv_python2:BOOL=(.*)$" )},
180
+ {'name' : "python3" , 'default' : None , 'pattern' : re .compile (r"^BUILD_opencv_python3:BOOL=(.*)$" )},
174
181
)
175
182
176
183
class CMakeCache :
@@ -247,18 +254,33 @@ def gatherTests(self, mask, isGood = None):
247
254
files = glob .glob (os .path .join (d , mask ))
248
255
if not self .getOS () == "android" and self .withJava ():
249
256
files .append ("java" )
257
+ if self .withPython ():
258
+ files .append ("python" )
259
+ if self .withPython2 ():
260
+ files .append ("python2" )
261
+ if self .withPython3 ():
262
+ files .append ("python3" )
250
263
return [f for f in files if isGood (f )]
251
264
return []
252
265
253
266
def isMainModule (self , name ):
254
- return name in self .main_modules
267
+ return name in self .main_modules + [ 'python' , 'python2' , 'python3' ]
255
268
256
269
def withCuda (self ):
257
270
return self .cuda_version and self .with_cuda == "ON" and self .cuda_library and not self .cuda_library .endswith ("-NOTFOUND" )
258
271
259
272
def withJava (self ):
260
273
return self .ant_executable and self .java_test_binary_dir
261
274
275
+ def withPython (self ):
276
+ return self .python == 'ON'
277
+
278
+ def withPython2 (self ):
279
+ return self .python2 == 'ON'
280
+
281
+ def withPython3 (self ):
282
+ return self .python3 == 'ON'
283
+
262
284
def getGitVersion (self ):
263
285
if self .cmake_home_vcver :
264
286
if self .cmake_home_vcver == self .opencv_home_vcver :
0 commit comments