def install(robustus, requirement_specifier, rob_file, ignore_index): assert requirement_specifier.name == 'ros_overlay' packages = requirement_specifier.version.split(',') cwd = os.getcwd() try: env_source = os.path.join(robustus.env, 'bin/activate') _ros_dep_init(env_source, robustus) # NOTE: If ROS is not installed, the following returns an empty string. def get_ros_install_dir(env_source): ret_code, output = run_shell('. "%s" && python -c "import ros ; print ros.__file__"' % env_source, shell=True, return_output=True) if ret_code != 0: logging.info('get_ros_install_dir() failed: ret_code is %d: %s' % (ret_code, output)) return '' if len(output.splitlines()) != 1: logging.info('get_ros_install_dir() failed: Too many lines in output: %s' % output) return '' output_dirname = os.path.dirname(output) ros_install_dir = os.path.abspath(os.path.join(output_dirname, os.pardir, os.pardir, os.pardir, os.pardir)) if not os.path.isdir(ros_install_dir): logging.info('get_ros_install_dir() failed: ros_install_dir not a directory: %s' % ros_install_dir) return '' return ros_install_dir ros_install_dir = get_ros_install_dir(env_source) req_name = "ros-installed-overlay" ver_hash = requirement_specifier.version_hash() logging.info('Hashing ROS overlay on (robustus.env, ver_hash, ros_install_dir) = ("%s", "%s", "%s")' % (robustus.env, ver_hash, ros_install_dir)) req_hash = ros_utils.hash_path(robustus.env, ver_hash, ros_install_dir) overlay_install_folder = os.path.join(robustus.cache, '%s-%s' % (req_name, req_hash)) if not os.path.isdir(overlay_install_folder): overlay_archive = robustus.download_compiled_archive(req_name, req_hash) if overlay_archive: overlay_archive_name = unpack(overlay_archive) logging.info('Initializing compiled ROS overlay') # install into wheelhouse safe_move(overlay_archive_name, overlay_install_folder) safe_remove(overlay_archive) else: overlay_src_folder = _make_overlay_folder(robustus, req_hash) os.chdir(overlay_src_folder) logging.info('Building ros overlay in %s with versions %s' ' install folder %s' % (overlay_src_folder, str(packages), overlay_install_folder)) os.mkdir(os.path.join(overlay_src_folder, 'src')) _get_sources(packages) _ros_dep(env_source, robustus) opencv_cmake_dir = _opencv_cmake_path(robustus) ret_code = run_shell('. "%s" && export OpenCV_DIR="%s" && catkin_make_isolated' ' --install-space %s --install' % (env_source, opencv_cmake_dir, overlay_install_folder) + ' --force-cmake --cmake-args -DCATKIN_ENABLE_TESTING=1 ', shell=True, verbose=robustus.settings['verbosity'] >= 1) if ret_code != 0: raise RequirementException('Error during catkin_make') else: logging.info('ROS overlay cached %s' % overlay_install_folder) add_source_ref(robustus, os.path.join(overlay_install_folder, 'setup.sh')) except RequirementException: if robustus.settings['debug']: logging.info('Not removing folder %s due to debug flag.' % overlay_src_folder) else: shutil.rmtree(overlay_src_folder, ignore_errors=True) shutil.rmtree(overlay_install_folder, ignore_errors=True) raise finally: os.chdir(cwd)
def install(robustus, requirement_specifier, rob_file, ignore_index): ''' Opencv has a lot of cmake flags. Here are some examples to play with: brew configuration for opencv 2.4.9: '-DCMAKE_OSX_DEPLOYMENT_TARGET=', '-DBUILD_ZLIB=OFF', '-DBUILD_TIFF=OFF', '-DBUILD_PNG=OFF', '-DBUILD_OPENEXR=OFF', '-DBUILD_JASPER=OFF', '-DBUILD_JPEG=OFF', '-DJPEG_INCLUDE_DIR=/usr/local/opt/jpeg/include', '-DJPEG_LIBRARY=/usr/local/opt/jpeg/lib/libjpeg.dylib', '-DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/Python', '-DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/Headers', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_opencv_java=OFF', '-DWITH_QT=OFF', '-DWITH_TBB=OFF', '-DWITH_FFMPEG=OFF', '-DWITH_OPENEXR=OFF', '-DWITH_CUDA=OFF', '-DWITH_OPENCL=OFF', '-DENABLE_SSSE3=ON', '-DENABLE_SSE41=ON', '-DENABLE_SSE42=ON', '-DENABLE_AVX=ON', ''' # Make sure numpy is installed - to avoid weird error when bindings # are silently not generated. if not check_module_available(robustus.env, 'numpy'): raise RequirementException('numpy is required for opencv') if platform.linux_distribution()[0] == 'CentOS': # linking opencv for CentOs logging.info('Linking opencv for CentOS') os.symlink('/usr/lib64/python2.7/site-packages/cv2.so', os.path.join(robustus.env, 'lib/python2.7/site-packages/cv2.so')) os.symlink('/usr/lib64/python2.7/site-packages/cv.py', os.path.join(robustus.env, 'lib/python2.7/site-packages/cv.py')) else: cv_install_dir = os.path.join(robustus.cache, 'OpenCV-%s' % requirement_specifier.version) cv2so = os.path.join(cv_install_dir, 'lib/python2.7/site-packages/cv2.so') def in_cache(): return os.path.isfile(cv2so) versions_to_fix_rpath = ['2.4.7', '2.4.8', '2.4.9'] if not in_cache() and not ignore_index: cwd = os.getcwd() opencv_archive = None opencv_archive_name = None try: opencv_archive = robustus.download_compiled_archive('OpenCV', requirement_specifier.version) if opencv_archive is not None: opencv_archive_name = unpack(opencv_archive) logging.info('Initializing compiled OpenCV') # install into wheelhouse safe_move(opencv_archive_name, cv_install_dir) else: opencv_archive = robustus.download('OpenCV', requirement_specifier.version) opencv_archive_name = unpack(opencv_archive) logging.info('Building OpenCV') cv_build_dir = os.path.join(opencv_archive_name, 'build') if not os.path.isdir(cv_build_dir): os.mkdir(cv_build_dir) os.chdir(cv_build_dir) opencv_cmake_call_args = [ 'cmake', '../', '-DPYTHON_EXECUTABLE=%s' % robustus.python_executable, '-DBUILD_NEW_PYTHON_SUPPORT=ON', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_DOCS=OFF', '-DBUILD_opencv_apps=OFF', '-DBUILD_opencv_java=OFF', '-DWITH_CUDA=OFF', '-DCMAKE_INSTALL_PREFIX=%s' % cv_install_dir] if sys.platform.startswith('darwin'): python_lib_path = subprocess.check_output(['python-config', '--prefix']).strip() opencv_cmake_call_args.append('-DPYTHON_LIBRARY=%s/Python' % python_lib_path) opencv_cmake_call_args.append('-DPYTHON_INCLUDE_DIR=%s/Headers' % python_lib_path) run_shell(opencv_cmake_call_args, verbose=robustus.settings['verbosity'] >= 1) retcode = run_shell(['make', '-j4'], verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('OpenCV build failed') # install into wheelhouse if not os.path.isdir(cv_install_dir): os.mkdir(cv_install_dir) retcode = run_shell(['make', 'install'], verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('OpenCV installation failed') finally: safe_remove(opencv_archive) safe_remove(opencv_archive_name) os.chdir(cwd) if in_cache() and requirement_specifier.version in versions_to_fix_rpath: # fix rpath for all dynamic libraries of cv2 all_cv_dlibs = os.path.abspath(os.path.join(cv_install_dir, 'lib')) if sys.platform.startswith('darwin'): libs = glob.glob(os.path.join(all_cv_dlibs, '*.dylib')) else: libs = glob.glob(os.path.join(all_cv_dlibs, '*.so')) for lib in libs: fix_rpath(robustus, robustus.env, lib, cv_install_dir) if in_cache(): logging.info('Copying OpenCV cv2.so to virtualenv') cp(os.path.join(cv_install_dir, 'lib/python2.7/site-packages/*'), os.path.join(robustus.env, 'lib/python2.7/site-packages')) if requirement_specifier.version in versions_to_fix_rpath: # fix rpath for cv2 cv2lib = os.path.join(robustus.env, 'lib/python2.7/site-packages/cv2.so') fix_rpath(robustus, robustus.env, cv2lib, cv_install_dir) else: raise RequirementException('can\'t find OpenCV-%s in robustus cache' % requirement_specifier.version)
def install(robustus, requirement_specifier, rob_file, ignore_index): assert requirement_specifier.name == 'ros_overlay' packages = requirement_specifier.version.split(',') cwd = os.getcwd() try: env_source = os.path.join(robustus.env, 'bin/activate') _ros_dep_init(env_source, robustus) # NOTE: If ROS is not installed, the following returns an empty string. def get_ros_install_dir(env_source): ret_code, output = run_shell( '. "%s" && python -c "import ros ; print ros.__file__"' % env_source, shell=True, return_output=True) if ret_code != 0: logging.info( 'get_ros_install_dir() failed: ret_code is %d: %s' % (ret_code, output)) return '' if len(output.splitlines()) != 1: logging.info( 'get_ros_install_dir() failed: Too many lines in output: %s' % output) return '' output_dirname = os.path.dirname(output) ros_install_dir = os.path.abspath( os.path.join(output_dirname, os.pardir, os.pardir, os.pardir, os.pardir)) if not os.path.isdir(ros_install_dir): logging.info( 'get_ros_install_dir() failed: ros_install_dir not a directory: %s' % ros_install_dir) return '' return ros_install_dir ros_install_dir = get_ros_install_dir(env_source) req_name = "ros-installed-overlay" ver_hash = requirement_specifier.version_hash() logging.info( 'Hashing ROS overlay on (robustus.env, ver_hash, ros_install_dir) = ("%s", "%s", "%s")' % (robustus.env, ver_hash, ros_install_dir)) req_hash = ros_utils.hash_path(robustus.env, ver_hash, ros_install_dir) overlay_install_folder = os.path.join(robustus.cache, '%s-%s' % (req_name, req_hash)) if not os.path.isdir(overlay_install_folder): overlay_archive = robustus.download_compiled_archive( req_name, req_hash) if overlay_archive: overlay_archive_name = unpack(overlay_archive) logging.info('Initializing compiled ROS overlay') # install into wheelhouse safe_move(overlay_archive_name, overlay_install_folder) safe_remove(overlay_archive) else: overlay_src_folder = _make_overlay_folder(robustus, req_hash) os.chdir(overlay_src_folder) logging.info('Building ros overlay in %s with versions %s' ' install folder %s' % (overlay_src_folder, str(packages), overlay_install_folder)) os.mkdir(os.path.join(overlay_src_folder, 'src')) _get_sources(packages) _ros_dep(env_source, robustus) opencv_cmake_dir = _opencv_cmake_path(robustus) ret_code = run_shell( '. "%s" && export OpenCV_DIR="%s" && catkin_make_isolated' ' --install-space %s --install' % (env_source, opencv_cmake_dir, overlay_install_folder) + ' --force-cmake --cmake-args -DCATKIN_ENABLE_TESTING=1 ', shell=True, verbose=robustus.settings['verbosity'] >= 1) if ret_code != 0: raise RequirementException('Error during catkin_make') else: logging.info('ROS overlay cached %s' % overlay_install_folder) add_source_ref(robustus, os.path.join(overlay_install_folder, 'setup.sh')) except RequirementException: if robustus.settings['debug']: logging.info('Not removing folder %s due to debug flag.' % overlay_src_folder) else: shutil.rmtree(overlay_src_folder, ignore_errors=True) shutil.rmtree(overlay_install_folder, ignore_errors=True) raise finally: os.chdir(cwd)
def install(robustus, requirement_specifier, rob_file, ignore_index): ver, dist = requirement_specifier.version.split('.') if platform.machine() == 'armv7l': # specific code to link ros on bstem ros_install_dir = os.path.join('/opt/bstem/bstem.ros', 'ros-install-%s' % requirement_specifier.version) if os.path.isdir(ros_install_dir): # check distro if (ver == 'hydro' and dist == 'ros_comm'): # Add ROS settings to activate file logging.info('Using ROS system install %s' % ros_install_dir) add_source_ref(robustus, os.path.join(ros_install_dir, 'setup.sh')) return else: logging.warn('armv7l only uses hydro.ros_comm as a ROS system install.\n') else: logging.warn('No suitable ROS system install found.\n') # check distro if ver != 'hydro': logging.warn('Robustus is only tested to install ROS hydro.\n' 'Still, it will try to install required distribution "%s"' % requirement_specifier.version) # install dependencies, may throw robustus.execute(['install', 'catkin_pkg==0.2.2', 'rosinstall==0.6.30', 'rosinstall_generator==0.1.4', 'wstool==0.0.4', 'empy==3.3.2', 'rosdep==0.10.27', 'sip']) ros_src_dir = os.path.join(robustus.env, 'ros-src-%s' % requirement_specifier.version) req_name = 'ros-install-%s' % requirement_specifier.version req_hash = ros_utils.hash_path(robustus.env) ros_install_dir = os.path.join(robustus.cache, '%s-%s' % (req_name, req_hash)) def in_cache(): return os.path.isdir(ros_install_dir) rosdep = _install_ros_deps(robustus) try: cwd = os.getcwd() logging.info('ROS install dir %s' % ros_install_dir) # download and install compiled non-system ROS or, if necessary, build ROS if not in_cache() and not ignore_index: ros_archive = robustus.download_compiled_archive(req_name, req_hash) if ros_archive: ros_archive_name = unpack(ros_archive) logging.info('Initializing compiled ROS in Robustus wheelhouse') # install into wheelhouse safe_move(ros_archive_name, ros_install_dir) safe_remove(ros_archive) else: logging.info('Building ROS in Robustus wheelhouse') if not os.path.isdir(ros_src_dir): os.makedirs(ros_src_dir) os.chdir(ros_src_dir) rosinstall_generator = os.path.join(robustus.env, 'bin/rosinstall_generator') retcode = run_shell(rosinstall_generator + ' %s --rosdistro %s' % (dist, ver) + ' --deps --wet-only > %s-%s-wet.rosinstall' % (dist, ver), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('Failed to generate rosinstall file') wstool = os.path.join(robustus.env, 'bin/wstool') retcode = run_shell(wstool + ' init -j2 src %s-%s-wet.rosinstall' % (dist, ver), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('Failed to build ROS') # resolve dependencies if sys.platform.startswith('darwin'): ros_os_param = '' else: ros_os_param = '--os=ubuntu:%s' % _get_distribution() retcode = run_shell(rosdep + ' install -r --from-paths src --ignore-src --rosdistro %s -y %s' % (ver, ros_os_param), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: if platform.machine() == 'armv7l': # Due to the lack of LISP machine for ARM we expect some failures logging.info("No LISP on ARM. Expected not all dependencies to be installed.") else: raise RequirementException('Failed to resolve ROS dependencies') # create catkin workspace py_activate_file = os.path.join(robustus.env, 'bin', 'activate') catkin_make_isolated = os.path.join(ros_src_dir, 'src/catkin/bin/catkin_make_isolated') retcode = run_shell('. ' + py_activate_file + ' && ' + catkin_make_isolated + ' --install-space %s --install' % ros_install_dir, shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('Failed to create catkin workspace for ROS') logging.info('Removing ROS source/build directory %s' % ros_src_dir) os.chdir(ros_install_dir) # NOTE: If this directory is not accessible, something is wrong. shutil.rmtree(ros_src_dir, ignore_errors=False) else: logging.info('Using ROS from cache %s' % ros_install_dir) os.chdir(cwd) # Add ROS settings to activate file add_source_ref(robustus, os.path.join(ros_install_dir, 'setup.sh')) except RequirementException: os.chdir(cwd) if robustus.settings['debug']: logging.info('Not removing folder %s due to debug flag.' % ros_src_dir) logging.info('Not removing folder %s due to debug flag.' % ros_install_dir) else: shutil.rmtree(ros_src_dir, ignore_errors=True) shutil.rmtree(ros_install_dir, ignore_errors=True) raise
def install(robustus, requirement_specifier, rob_file, ignore_index): ver, dist = requirement_specifier.version.split('.') if platform.machine() == 'armv7l': # specific code to link ros on bstem ros_install_dir = os.path.join( '/opt/bstem/bstem.ros', 'ros-install-%s' % requirement_specifier.version) if os.path.isdir(ros_install_dir): # check distro if (ver == 'hydro' and dist == 'ros_comm'): # Add ROS settings to activate file logging.info('Using ROS system install %s' % ros_install_dir) add_source_ref(robustus, os.path.join(ros_install_dir, 'setup.sh')) return else: logging.warn( 'armv7l only uses hydro.ros_comm as a ROS system install.\n' ) else: logging.warn('No suitable ROS system install found.\n') # check distro if ver != 'hydro': logging.warn( 'Robustus is only tested to install ROS hydro.\n' 'Still, it will try to install required distribution "%s"' % requirement_specifier.version) # install dependencies, may throw robustus.execute([ 'install', 'catkin_pkg==0.2.2', 'rosinstall==0.6.30', 'rosinstall_generator==0.1.4', 'wstool==0.0.4', 'empy==3.3.2', 'rosdep==0.10.27', 'sip' ]) ros_src_dir = os.path.join(robustus.env, 'ros-src-%s' % requirement_specifier.version) req_name = 'ros-install-%s' % requirement_specifier.version req_hash = ros_utils.hash_path(robustus.env) ros_install_dir = os.path.join(robustus.cache, '%s-%s' % (req_name, req_hash)) def in_cache(): return os.path.isdir(ros_install_dir) rosdep = _install_ros_deps(robustus) try: cwd = os.getcwd() logging.info('ROS install dir %s' % ros_install_dir) # download and install compiled non-system ROS or, if necessary, build ROS if not in_cache() and not ignore_index: ros_archive = robustus.download_compiled_archive( req_name, req_hash) if ros_archive: ros_archive_name = unpack(ros_archive) logging.info( 'Initializing compiled ROS in Robustus wheelhouse') # install into wheelhouse safe_move(ros_archive_name, ros_install_dir) safe_remove(ros_archive) else: logging.info('Building ROS in Robustus wheelhouse') if not os.path.isdir(ros_src_dir): os.makedirs(ros_src_dir) os.chdir(ros_src_dir) rosinstall_generator = os.path.join( robustus.env, 'bin/rosinstall_generator') retcode = run_shell( rosinstall_generator + ' %s --rosdistro %s' % (dist, ver) + ' --deps --wet-only > %s-%s-wet.rosinstall' % (dist, ver), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException( 'Failed to generate rosinstall file') wstool = os.path.join(robustus.env, 'bin/wstool') retcode = run_shell( wstool + ' init -j2 src %s-%s-wet.rosinstall' % (dist, ver), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('Failed to build ROS') # resolve dependencies if sys.platform.startswith('darwin'): ros_os_param = '' else: ros_os_param = '--os=ubuntu:%s' % _get_distribution() retcode = run_shell( rosdep + ' install -r --from-paths src --ignore-src --rosdistro %s -y %s' % (ver, ros_os_param), shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: if platform.machine() == 'armv7l': # Due to the lack of LISP machine for ARM we expect some failures logging.info( "No LISP on ARM. Expected not all dependencies to be installed." ) else: raise RequirementException( 'Failed to resolve ROS dependencies') # create catkin workspace py_activate_file = os.path.join(robustus.env, 'bin', 'activate') catkin_make_isolated = os.path.join( ros_src_dir, 'src/catkin/bin/catkin_make_isolated') retcode = run_shell( '. ' + py_activate_file + ' && ' + catkin_make_isolated + ' --install-space %s --install' % ros_install_dir, shell=True, verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException( 'Failed to create catkin workspace for ROS') logging.info('Removing ROS source/build directory %s' % ros_src_dir) os.chdir( ros_install_dir ) # NOTE: If this directory is not accessible, something is wrong. shutil.rmtree(ros_src_dir, ignore_errors=False) else: logging.info('Using ROS from cache %s' % ros_install_dir) os.chdir(cwd) # Add ROS settings to activate file add_source_ref(robustus, os.path.join(ros_install_dir, 'setup.sh')) except RequirementException: os.chdir(cwd) if robustus.settings['debug']: logging.info('Not removing folder %s due to debug flag.' % ros_src_dir) logging.info('Not removing folder %s due to debug flag.' % ros_install_dir) else: shutil.rmtree(ros_src_dir, ignore_errors=True) shutil.rmtree(ros_install_dir, ignore_errors=True) raise
def install(robustus, requirement_specifier, rob_file, ignore_index): ''' Opencv has a lot of cmake flags. Here are some examples to play with: brew configuration for opencv 2.4.9: '-DCMAKE_OSX_DEPLOYMENT_TARGET=', '-DBUILD_ZLIB=OFF', '-DBUILD_TIFF=OFF', '-DBUILD_PNG=OFF', '-DBUILD_OPENEXR=OFF', '-DBUILD_JASPER=OFF', '-DBUILD_JPEG=OFF', '-DJPEG_INCLUDE_DIR=/usr/local/opt/jpeg/include', '-DJPEG_LIBRARY=/usr/local/opt/jpeg/lib/libjpeg.dylib', '-DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/Python', '-DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/Headers', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_opencv_java=OFF', '-DWITH_QT=OFF', '-DWITH_TBB=OFF', '-DWITH_FFMPEG=OFF', '-DWITH_OPENEXR=OFF', '-DWITH_CUDA=OFF', '-DWITH_OPENCL=OFF', '-DENABLE_SSSE3=ON', '-DENABLE_SSE41=ON', '-DENABLE_SSE42=ON', '-DENABLE_AVX=ON', ''' # Make sure numpy is installed - to avoid weird error when bindings # are silently not generated. if not check_module_available(robustus.env, 'numpy'): raise RequirementException('numpy is required for opencv') if platform.linux_distribution()[0] == 'CentOS': # linking opencv for CentOs logging.info('Linking opencv for CentOS') os.symlink('/usr/lib64/python2.7/site-packages/cv2.so', os.path.join(robustus.env, 'lib/python2.7/site-packages/cv2.so')) os.symlink('/usr/lib64/python2.7/site-packages/cv.py', os.path.join(robustus.env, 'lib/python2.7/site-packages/cv.py')) else: cv_install_dir = os.path.join(robustus.cache, 'OpenCV-%s' % requirement_specifier.version) cv2so = os.path.join(cv_install_dir, 'lib/python2.7/site-packages/cv2.so') def in_cache(): return os.path.isfile(cv2so) if not in_cache() and not ignore_index: cwd = os.getcwd() opencv_archive = None opencv_archive_name = None try: opencv_archive = robustus.download_compiled_archive('OpenCV', requirement_specifier.version) if opencv_archive is not None: opencv_archive_name = unpack(opencv_archive) logging.info('Initializing compiled OpenCV') # install into wheelhouse safe_move(opencv_archive_name, cv_install_dir) else: opencv_archive = robustus.download('OpenCV', requirement_specifier.version) opencv_archive_name = unpack(opencv_archive) logging.info('Building OpenCV') cv_build_dir = os.path.join(opencv_archive_name, 'build') if not os.path.isdir(cv_build_dir): os.mkdir(cv_build_dir) os.chdir(cv_build_dir) opencv_cmake_call_args = [ 'cmake', '../', '-DPYTHON_EXECUTABLE=%s' % robustus.python_executable, '-DBUILD_NEW_PYTHON_SUPPORT=ON', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_DOCS=OFF', '-DBUILD_opencv_apps=OFF', '-DBUILD_opencv_java=OFF', '-DWITH_CUDA=OFF', '-DCMAKE_INSTALL_PREFIX=%s' % cv_install_dir] if sys.platform.startswith('darwin'): python_lib_path = subprocess.check_output(['python-config', '--prefix']).strip() opencv_cmake_call_args.append('-DPYTHON_LIBRARY=%s/Python' % python_lib_path) opencv_cmake_call_args.append('-DPYTHON_INCLUDE_DIR=%s/Headers' % python_lib_path) run_shell(opencv_cmake_call_args, verbose=robustus.settings['verbosity'] >= 1) retcode = run_shell(['make', '-j4'], verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('OpenCV build failed') # install into wheelhouse if not os.path.isdir(cv_install_dir): os.mkdir(cv_install_dir) retcode = run_shell(['make', 'install'], verbose=robustus.settings['verbosity'] >= 1) if retcode != 0: raise RequirementException('OpenCV installation failed') finally: safe_remove(opencv_archive) safe_remove(opencv_archive_name) os.chdir(cwd) if in_cache(): # fix rpath for all dynamic libraries of cv2 all_cv_dlibs = os.path.abspath(os.path.join(cv_install_dir, 'lib')) if sys.platform.startswith('darwin'): libs = glob.glob(os.path.join(all_cv_dlibs, '*.dylib')) else: libs = glob.glob(os.path.join(all_cv_dlibs, '*.so')) for lib in libs: fix_rpath(robustus, robustus.env, lib, cv_install_dir) if in_cache(): logging.info('Copying OpenCV cv2.so to virtualenv') cp(os.path.join(cv_install_dir, 'lib/python2.7/site-packages/*'), os.path.join(robustus.env, 'lib/python2.7/site-packages')) # fix rpath for cv2 cv2lib = os.path.join(robustus.env, 'lib/python2.7/site-packages/cv2.so') fix_rpath(robustus, robustus.env, cv2lib, cv_install_dir) else: raise RequirementException('can\'t find OpenCV-%s in robustus cache' % requirement_specifier.version)