From ccafe2b9207ca1654c8cc4a69b9e674cbe7c5b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 11 Feb 2020 15:00:43 -0300 Subject: [PATCH 1/4] pythonPackages.mutagen: 1.42.0 -> 1.43.0 Not updating to 1.44.0 due to it dropping Python 2 support. --- .../python-modules/mutagen/default.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pkgs/development/python-modules/mutagen/default.nix b/pkgs/development/python-modules/mutagen/default.nix index 0bd08a82b937e..304aeead76ff0 100644 --- a/pkgs/development/python-modules/mutagen/default.nix +++ b/pkgs/development/python-modules/mutagen/default.nix @@ -6,24 +6,20 @@ , pycodestyle , pyflakes , pytest +, setuptools , pkgs }: buildPythonPackage rec { pname = "mutagen"; - version = "1.42.0"; + version = "1.43.0"; src = fetchPypi { inherit pname version; - sha256 = "bb61e2456f59a9a4a259fbc08def6d01ba45a42da8eeaa97d00633b0ec5de71c"; - }; - - # fix tests with updated pycodestyle - patches = fetchpatch { - url = https://github.com/quodlibet/mutagen/commit/0ee86ef9d7e06639a388d0638732810b79998608.patch; - sha256 = "1bj3mpbv7krh5m1mvfl0z18s8wdxb1949zcnkcqxp2xl5fzsi288"; + sha256 = "3a982d39f1b800520a32afdebe3543f972e83a6ddd0c0198739a161ee705b588"; }; + propagatedBuildInputs = [ setuptools ]; checkInputs = [ pkgs.faad2 pkgs.flac pkgs.vorbis-tools pkgs.liboggz pkgs.glibcLocales pycodestyle pyflakes pytest hypothesis @@ -32,7 +28,8 @@ buildPythonPackage rec { meta = with lib; { description = "Python multimedia tagging library"; - homepage = https://mutagen.readthedocs.io/; + homepage = "https://mutagen.readthedocs.io"; license = licenses.lgpl2Plus; + platforms = platforms.all; }; } From 746ab5ad740258528e64d1623181cf0d7b9f5f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Thu, 13 Feb 2020 15:07:33 -0300 Subject: [PATCH 2/4] beets: Fix test to work with mutagen>=1.43 --- pkgs/tools/audio/beets/default.nix | 1 + pkgs/tools/audio/beets/mutagen-1.43.patch | 29 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/tools/audio/beets/mutagen-1.43.patch diff --git a/pkgs/tools/audio/beets/default.nix b/pkgs/tools/audio/beets/default.nix index b4dfa71ca965d..1eb8dd114f5fd 100644 --- a/pkgs/tools/audio/beets/default.nix +++ b/pkgs/tools/audio/beets/default.nix @@ -177,6 +177,7 @@ in pythonPackages.buildPythonApplication rec { patches = [ ./replaygain-default-bs1770gain.patch ./keyfinder-default-bin.patch + ./mutagen-1.43.patch ]; postPatch = '' diff --git a/pkgs/tools/audio/beets/mutagen-1.43.patch b/pkgs/tools/audio/beets/mutagen-1.43.patch new file mode 100644 index 0000000000000..84cf1bab03ec8 --- /dev/null +++ b/pkgs/tools/audio/beets/mutagen-1.43.patch @@ -0,0 +1,29 @@ +Backport https://github.com/beetbox/mediafile/commit/b3343c4ee08d1251ae5e2344401a2f5892b4e868 +to Beets 1.4.9. + +diff --git i/setup.py w/setup.py +index 79278f8..b8d6068 100755 +--- i/setup.py ++++ w/setup.py +@@ -87,7 +87,7 @@ setup( + + install_requires=[ + 'six>=1.9', +- 'mutagen>=1.33', ++ 'mutagen>=1.43', + 'unidecode', + 'musicbrainzngs>=0.4', + 'pyyaml', +diff --git i/test/test_mediafile.py w/test/test_mediafile.py +index 36a2c53..54ef9dd 100644 +--- i/test/test_mediafile.py ++++ w/test/test_mediafile.py +@@ -912,7 +912,7 @@ class AIFFTest(ReadWriteTestBase, unittest.TestCase): + 'bitrate': 705600, + 'format': u'AIFF', + 'samplerate': 44100, +- 'bitdepth': 0, ++ 'bitdepth': 16, + 'channels': 1, + } + From 1d56f9665c4a2953d23f0a6dd981c6b413721a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 11 Feb 2020 15:02:07 -0300 Subject: [PATCH 3/4] pythonPackages.ffmpeg-python: init at 0.2.0 --- .../python-modules/ffmpeg-python/default.nix | 43 ++++++++++ .../ffmpeg-python/ffmpeg-location.patch | 84 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 129 insertions(+) create mode 100644 pkgs/development/python-modules/ffmpeg-python/default.nix create mode 100644 pkgs/development/python-modules/ffmpeg-python/ffmpeg-location.patch diff --git a/pkgs/development/python-modules/ffmpeg-python/default.nix b/pkgs/development/python-modules/ffmpeg-python/default.nix new file mode 100644 index 0000000000000..ae7dc43020b5f --- /dev/null +++ b/pkgs/development/python-modules/ffmpeg-python/default.nix @@ -0,0 +1,43 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, substituteAll +, ffmpeg +, future +, pytest +, pytestrunner +, pytest-mock +}: + +buildPythonPackage rec { + pname = "ffmpeg-python"; + version = "0.2.0"; + + src = fetchFromGitHub { + owner = "kkroening"; + repo = "ffmpeg-python"; + rev = version; + sha256 = "0mmydmfz3yiclbgi4lqrv9fh2nalafg4bkm92y2qi50mwqgffk8f"; + }; + + patches = [ + ( + substituteAll { + src = ./ffmpeg-location.patch; + inherit ffmpeg; + } + ) + ]; + + buildInputs = [ pytestrunner ]; + propagatedBuildInputs = [ future ]; + checkInputs = [ pytest pytest-mock ]; + + meta = with lib; { + description = "Python bindings for FFmpeg - with complex filtering support"; + homepage = "https://github.com/kkroening/ffmpeg-python"; + license = licenses.asl20; + maintainers = [ maintainers.AluisioASG ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/python-modules/ffmpeg-python/ffmpeg-location.patch b/pkgs/development/python-modules/ffmpeg-python/ffmpeg-location.patch new file mode 100644 index 0000000000000..a192504e12675 --- /dev/null +++ b/pkgs/development/python-modules/ffmpeg-python/ffmpeg-location.patch @@ -0,0 +1,84 @@ +diff --git i/ffmpeg/_probe.py w/ffmpeg/_probe.py +index 41e8168..eb83b54 100644 +--- i/ffmpeg/_probe.py ++++ w/ffmpeg/_probe.py +@@ -4,7 +4,7 @@ from ._run import Error + from ._utils import convert_kwargs_to_cmd_line_args + + +-def probe(filename, cmd='ffprobe', **kwargs): ++def probe(filename, cmd='@ffmpeg@/bin/ffprobe', **kwargs): + """Run ffprobe on the specified file and return a JSON representation of the output. + + Raises: +diff --git i/ffmpeg/_run.py w/ffmpeg/_run.py +index afc504d..9445cca 100644 +--- i/ffmpeg/_run.py ++++ w/ffmpeg/_run.py +@@ -172,7 +172,7 @@ def get_args(stream_spec, overwrite_output=False): + + + @output_operator() +-def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): ++def compile(stream_spec, cmd='@ffmpeg@/bin/ffmpeg', overwrite_output=False): + """Build command-line for invoking ffmpeg. + + The :meth:`run` function uses this to build the commnad line +@@ -193,7 +193,7 @@ def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): + @output_operator() + def run_async( + stream_spec, +- cmd='ffmpeg', ++ cmd='@ffmpeg@/bin/ffmpeg', + pipe_stdin=False, + pipe_stdout=False, + pipe_stderr=False, +@@ -289,7 +289,7 @@ def run_async( + @output_operator() + def run( + stream_spec, +- cmd='ffmpeg', ++ cmd='@ffmpeg@/bin/ffmpeg', + capture_stdout=False, + capture_stderr=False, + input=None, +diff --git i/ffmpeg/tests/test_ffmpeg.py w/ffmpeg/tests/test_ffmpeg.py +index 279a323..8d3b35c 100644 +--- i/ffmpeg/tests/test_ffmpeg.py ++++ w/ffmpeg/tests/test_ffmpeg.py +@@ -24,7 +24,7 @@ TEST_OUTPUT_FILE2 = os.path.join(SAMPLE_DATA_DIR, 'out2.mp4') + BOGUS_INPUT_FILE = os.path.join(SAMPLE_DATA_DIR, 'bogus') + + +-subprocess.check_call(['ffmpeg', '-version']) ++subprocess.check_call(['@ffmpeg@/bin/ffmpeg', '-version']) + + + def test_escape_chars(): +@@ -423,7 +423,7 @@ def test_filter_text_arg_str_escape(): + + def test__compile(): + out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4') +- assert out_file.compile() == ['ffmpeg', '-i', 'dummy.mp4', 'dummy2.mp4'] ++ assert out_file.compile() == ['@ffmpeg@/bin/ffmpeg', '-i', 'dummy.mp4', 'dummy2.mp4'] + assert out_file.compile(cmd='ffmpeg.old') == [ + 'ffmpeg.old', + '-i', +@@ -490,7 +490,7 @@ def test__run__input_output(mocker): + @pytest.mark.parametrize('capture_stdout', [True, False]) + @pytest.mark.parametrize('capture_stderr', [True, False]) + def test__run__error(mocker, capture_stdout, capture_stderr): +- mocker.patch.object(ffmpeg._run, 'compile', return_value=['ffmpeg']) ++ mocker.patch.object(ffmpeg._run, 'compile', return_value=['@ffmpeg@/bin/ffmpeg']) + stream = _get_complex_filter_example() + with pytest.raises(ffmpeg.Error) as excinfo: + out, err = ffmpeg.run( +@@ -684,7 +684,7 @@ def test_pipe(): + 'pipe:1', + ] + +- cmd = ['ffmpeg'] + args ++ cmd = ['@ffmpeg@/bin/ffmpeg'] + args + p = subprocess.Popen( + cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 02c6ef3cd2652..b0354ca8fb5fb 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2634,6 +2634,8 @@ in { fb-re2 = callPackage ../development/python-modules/fb-re2 { }; + ffmpeg-python = callPackage ../development/python-modules/ffmpeg-python { }; + filetype = callPackage ../development/python-modules/filetype { }; flammkuchen = callPackage ../development/python-modules/flammkuchen { }; From 98e2817df4382f4be64034816e2c8be8c6dfd4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alu=C3=ADsio=20Augusto=20Silva=20Gon=C3=A7alves?= Date: Tue, 11 Feb 2020 15:02:24 -0300 Subject: [PATCH 4/4] r128gain: 0.9.3 -> 1.0.1 Switched the source to GitHub so that test files are available for local, unsandboxed testing. --- pkgs/applications/audio/r128gain/default.nix | 36 ++++++++++++++----- .../audio/r128gain/ffmpeg-location.patch | 31 ++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 pkgs/applications/audio/r128gain/ffmpeg-location.patch diff --git a/pkgs/applications/audio/r128gain/default.nix b/pkgs/applications/audio/r128gain/default.nix index c4d8a1c20167e..fb2b306327611 100644 --- a/pkgs/applications/audio/r128gain/default.nix +++ b/pkgs/applications/audio/r128gain/default.nix @@ -1,19 +1,37 @@ -{ lib, python3Packages, ffmpeg }: +{ lib +, fetchFromGitHub +, substituteAll +, ffmpeg +, python3Packages +, sox +}: python3Packages.buildPythonApplication rec { pname = "r128gain"; - version = "0.9.3"; + version = "1.0.1"; - src = python3Packages.fetchPypi { - inherit pname version; - sha256 = "0dx2grryp0lj58bawx1zcq9a6b4ijz9r5qrg8h6nvm92kqlya26i"; + src = fetchFromGitHub { + owner = "desbma"; + repo = "r128gain"; + rev = version; + sha256 = "0fnxis2g7mw8mb0cz9bws909lrndli7ml54nnzda49vc2fhbjwxr"; }; - propagatedBuildInputs = [ ffmpeg ] - ++ (with python3Packages; [ crcmod mutagen tqdm ]) - ; + patches = [ + ( + substituteAll { + src = ./ffmpeg-location.patch; + inherit ffmpeg; + } + ) + ]; - doCheck = false; # downloads media files for testing + propagatedBuildInputs = with python3Packages; [ crcmod ffmpeg-python mutagen tqdm ]; + checkInputs = with python3Packages; [ requests sox ]; + + # Testing downloads media files for testing, which requires the + # sandbox to be disabled. + doCheck = false; meta = with lib; { description = "Fast audio loudness scanner & tagger (ReplayGain v2 / R128)"; diff --git a/pkgs/applications/audio/r128gain/ffmpeg-location.patch b/pkgs/applications/audio/r128gain/ffmpeg-location.patch new file mode 100644 index 0000000000000..ff118024011ef --- /dev/null +++ b/pkgs/applications/audio/r128gain/ffmpeg-location.patch @@ -0,0 +1,31 @@ +diff --git i/r128gain/__init__.py w/r128gain/__init__.py +index 53fc3ef..f144e15 100755 +--- i/r128gain/__init__.py ++++ w/r128gain/__init__.py +@@ -78,7 +78,7 @@ def get_ffmpeg_lib_versions(ffmpeg_path=None): + Example: 0x3040100 for FFmpeg 3.4.1 + """ + r = collections.OrderedDict() +- cmd = (ffmpeg_path or "ffmpeg", "-version") ++ cmd = (ffmpeg_path or "@ffmpeg@/bin/ffmpeg", "-version") + output = subprocess.run(cmd, + check=True, + stdout=subprocess.PIPE, +@@ -156,7 +156,7 @@ def get_r128_loudness(audio_filepaths, *, calc_peak=True, enable_ffmpeg_threadin + os.devnull, + **additional_ffmpeg_args, + f="null"), +- cmd=ffmpeg_path or "ffmpeg") ++ cmd=ffmpeg_path or "@ffmpeg@/bin/ffmpeg") + + # run + logger().debug(cmd_to_string(cmd)) +@@ -740,7 +740,7 @@ def cl_main(): + help="Maximum number of tracks to scan in parallel. If not specified, autodetect CPU count") + arg_parser.add_argument("-f", + "--ffmpeg-path", +- default=shutil.which("ffmpeg"), ++ default="@ffmpeg@/bin/ffmpeg", + help="""Full file path of ffmpeg executable (only needed if not in PATH). + If not specified, autodetect""") + arg_parser.add_argument("-d",