From b74974e55d2420a584d8f78ba0cad8c2afb1e71e Mon Sep 17 00:00:00 2001 From: tguinot <thomas.guinot@gmail.com> Date: Mon, 10 Feb 2020 03:31:07 +0100 Subject: [PATCH] Add which pathfinding for executables --- README.md | 12 ++++++++++++ libmat2/bubblewrap.py | 4 ++++ libmat2/exiftool.py | 5 +++++ libmat2/video.py | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/README.md b/README.md index 2aeb493..9cbc258 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,18 @@ Nautilus, the default file manager of GNOME. Please note that mat2 requires at least Python3.5. +# Requirements setup on macOS (OS X) using Homewbrew + +```bash +brew install exiftool +brew install cairo +brew install pygobject3 +brew install poppler +brew install gdk-pixbuf +brew install librsvg +brew install ffmpeg +``` + # Running the test suite ```bash diff --git a/libmat2/bubblewrap.py b/libmat2/bubblewrap.py index 7a70635..b859cf7 100644 --- a/libmat2/bubblewrap.py +++ b/libmat2/bubblewrap.py @@ -22,6 +22,10 @@ CalledProcessError = subprocess.CalledProcessError def _get_bwrap_path() -> str: + which_path = shutil.which('bwrap') + if which_path is not None and os.access(which_path, os.X_OK): + return which_path + bwrap_path = '/usr/bin/bwrap' if os.path.isfile(bwrap_path): if os.access(bwrap_path, os.X_OK): diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py index 1ce60a1..091213a 100644 --- a/libmat2/exiftool.py +++ b/libmat2/exiftool.py @@ -2,6 +2,7 @@ import functools import json import logging import os +import shutil import subprocess from typing import Dict, Union, Set @@ -71,6 +72,10 @@ class ExiftoolParser(abstract.AbstractParser): @functools.lru_cache() def _get_exiftool_path() -> str: # pragma: no cover + which_path = shutil.which('exiftool') + if which_path is not None and os.access(which_path, os.X_OK): + return which_path + possible_pathes = { '/usr/bin/exiftool', # debian/fedora '/usr/bin/vendor_perl/exiftool', # archlinux diff --git a/libmat2/video.py b/libmat2/video.py index 2b33bc0..f513e61 100644 --- a/libmat2/video.py +++ b/libmat2/video.py @@ -1,6 +1,7 @@ import subprocess import functools import os +import shutil import logging from typing import Dict, Union @@ -137,6 +138,10 @@ class MP4Parser(AbstractFFmpegParser): @functools.lru_cache() def _get_ffmpeg_path() -> str: # pragma: no cover + which_path = shutil.which('ffmpeg') + if which_path is not None and os.access(which_path, os.X_OK): + return which_path + ffmpeg_path = '/usr/bin/ffmpeg' if os.path.isfile(ffmpeg_path): if os.access(ffmpeg_path, os.X_OK): -- GitLab