diff --git a/var/spack/repos/builtin/packages/opencv/package.py b/var/spack/repos/builtin/packages/opencv/package.py index 9c17cff591..3d887f0775 100644 --- a/var/spack/repos/builtin/packages/opencv/package.py +++ b/var/spack/repos/builtin/packages/opencv/package.py @@ -58,6 +58,8 @@ class Opencv(Package): depends_on('eigen', when='+eigen') depends_on('cuda', when='+cuda') + extends('python') + # FIXME : GUI extensions missing def install(self, spec, prefix): @@ -70,6 +72,19 @@ def install(self, spec, prefix): '-DWITH_IPP:BOOL=%s' % ('ON' if '+ipp' in spec else 'OFF'), '-DWITH_CUDA:BOOL=%s' % ('ON' if '+cuda' in spec else 'OFF')]) + python_prefix = spec['python'].prefix + python_lib = python_prefix.lib + if spec.satisfies('^python@3:'): + python = join_path(python_prefix.bin, 'python3') + cmake_options.extend(['-DBUILD_opencv_python3=ON', + '-DPYTHON_EXECUTABLE={0}'.format(python), + '-DPYTHON_LIBRARIES={0}'.format(python_lib)]) + elif spec.satisfies('^python@2:3'): + python = join_path(python_prefix.bin, 'python2') + cmake_options.extend(['-DBUILD_opencv_python2=ON', + '-DPYTHON_EXECUTABLE={0}'.format(python), + '-DPYTHON_LIBRARIES={0}'.format(python_lib)]) + with working_dir('spack_build', create=True): cmake('..', *cmake_options) make('VERBOSE=1')