Exemplo n.º 1
0
def get_python_libs_dir():
    if is_windows():
        caller_dir = get_first_caller_dir()
        if caller_dir:
            return os.path.join(caller_dir, 'libs')
        return ""
    else:
        raise NotImplementedError()
Exemplo n.º 2
0
 def init_venv(self):
     if self.have_venv():
         return
     self.log.write('initializing python virtual environment {}'.format(self.get_name()))
     try:
         if is_windows():
             run(['virtualenv', os.path.join(get_root_dir(), self.get_name())])
         else:
             run(['virtualenv', '--python=python3.5', os.path.join(get_root_dir(), self.get_name())])
     except Exception as e:
         self.log.exit_nicely('python virtual environment creation error', e)
Exemplo n.º 3
0
def check_ambient():
    if '--no-checks' in sys.argv:
        return True
    sys.argv = sys.argv + ['--no-checks']
    if sys.version_info < (3, 5):
        BuildLog().exit_nicely('you should run setup.py with python 3.5 or above')
    if is_windows():
        BuildLog().exit_nicely('sorry not made for windows :D')
    checker = DependencyChecker()
    checker.add('cmake', 'CMake', ['cmake', '--version'])
    checker.add('virtualenv', 'Python Virtual Environment', ['virtualenv', '--version'])
    checker.add('git', 'GIT', ['git', '--version'])
    checker.add('g++', 'G++ Compiler', ['g++', '--version'])
    checker.check()
Exemplo n.º 4
0
 def configure_opencv(self):
     self.check_ffmpeg()
     if os.path.exists(self.ocv_build_dir):
         self.log.write(
             'the opencv was already configured.' +
             ' if you want to reconfigure it remove the directory {}'.format(self.ocv_build_dir))
         return
     self.log.write('Configuring opencv')
     try:
         os.makedirs(self.ocv_build_dir)
         current_dir = os.getcwd()
         os.chdir(self.ocv_build_dir)
         cmake_params = [
             'cmake', '-D', 'CMAKE_BUILD_TYPE=RELEASE',
             '-D', 'CMAKE_INSTALL_PREFIX={}'.format(self.ocv_build_dir),
             '-D', 'INSTALL_C_EXAMPLES=OFF',
             '-D', 'INSTALL_PYTHON_EXAMPLES=OFF',
             '-D', 'BUILD_EXAMPLES=OFF',
             '-D', 'USE_FFMPEG=ON',
             '-D', 'BUILD_opencv_python2=OFF',
             '-D', 'BUILD_opencv_python3=ON',
             '-D', 'OPENCV_EXTRA_MODULES_PATH={}/modules'.format(self.ocv_contrib_dir),
             '-D', 'PYTHON3_EXECUTABLE={}'.format(os.path.join(get_first_caller_dir(), 'python3.5')),
             '-D', 'FFMPEG_INCLUDE_DIR={}'.format(os.path.join(self.ffmpeg_dir, 'include'))
         ]
         if is_windows():
             cmake_params += [
                 '-D', 'WITH_IPP=OFF',
                 '-D', 'BUILD_opencv_line_descriptor=OFF',
                 '-D', 'BUILD_opencv_datasets=OFF',
                 '-D', 'WITH_DSHOW=OFF',
                 '-D', 'BUILD_opencv_python2=OFF',
                 '-D', 'PYTHON_INCLUDE_DIR={}'.format(get_python_include_dir()),
                 '-D', 'PYTHON_LIBRARY={}'.format(os.path.join(get_python_libs_dir(), 'libpython35.a'))
             ]
             cmake_params += ['-D', 'CMAKE_SH=']
             cmake_params += ['-G', 'MinGW Makefiles']
         cmake_params = cmake_params + [self.ocv_dir]
         run(cmake_params)
         os.chdir(current_dir)
     except Exception as e:
         print(str(e))
         self.log.exit_nicely('falha configurando opencv.', e)
Exemplo n.º 5
0
    def compile_ffopencv(self):
        if not is_windows():
            return
        self.check_ffmpeg()
        ffmpeg_idir = os.path.join(self.ffmpeg_dir, 'include')
        ffmpeg_ldir = os.path.join(self.ffmpeg_dir, 'lib')
        opencv_sdir = os.path.join(self.local_dir, '{}/modules/highgui/include'.format(OPENCV_DIR))
        opencv_cap_dir = os.path.join(self.local_dir, '{}/modules/videoio/src'.format(OPENCV_DIR))
        ffopencv_src = os.path.join(self.local_dir, '{}/3rdparty/ffmpeg/ffopencv.c'.format(OPENCV_DIR))
        ffopencv_out = os.path.join(self.install_dir, 'opencv_ffmpeg.dll')
        if not os.path.exists(self.install_dir):
            os.makedirs(self.install_dir)

        build_command = [
            'gcc', '-Wall', '-shared', '-o', ffopencv_out, '-O2', '-x', 'c++',
            '-I{}'.format(opencv_cap_dir), '-I{}'.format(ffmpeg_idir), '-I{}'.format(opencv_sdir),
            ffopencv_src, '-L{}'.format(ffmpeg_ldir), '-lavformat.dll', '-lavcodec.dll', '-lavdevice.dll',
            '-lswscale.dll', '-lavutil.dll'
        ]
        try:
            run(build_command)
        except Exception as e:
            self.log.exit_nicely('fail compiling opencv_ffmpeg.dll comando {}'.format(str(build_command)), e)