python-librosa/librosa-create-pooch-cache.py
Markéta Machová 2cac8b1da2 - Switch ffmpeg-5 with ffmpeg-4 BuildRequires: python-librosa is
the last package depending on ffmepeg-5, and it's only used for
  testsuite, so using ffmepeg-4 is fine, and will allow us to drop
  ffmpeg-5 from distro.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-librosa?expand=0&rev=55
2025-01-28 10:36:09 +00:00

48 lines
1.6 KiB
Python

""" librosa-create-pooch-cache.py
Create the pooch cache tarball for testing the package.
Copyright (c) 2021 SUSE LLC
Copyright (c) 2021 Ben Greiner <code@bnavigator.de>
All modifications and additions to the file contributed by third parties
remain the property of their copyright owners, unless otherwise agreed
upon. The license for this file, and modifications and additions to the
file, is the same license as for the pristine package itself (unless the
license for the pristine package is not an Open Source License, in which
case the license is the MIT License). An "Open Source License" is a
license that conforms to the Open Source Definition (Version 1.9)
published by the Open Source Initiative.
Please submit bugfixes or comments via https://bugs.opensuse.org/
"""
import os
import subprocess
import sys
import pooch
data_name = "librosa-pooch-cache"
registry_file = "librosa/util/example_data/registry.txt"
if len(sys.argv) != 2:
print(f"Usage: python3 {sys.argv[0]} <librosa-srcdir>")
print(f"Download test data into $PWD/{data_name} and compress the directory into $PWD/{data_name}.tar.gz")
sys.exit(1)
srcdir = os.path.abspath(sys.argv[1])
data_path = os.path.abspath(os.getcwd() + "/" + data_name)
pc = pooch.create(
data_path, base_url="https://librosa.org/data/audio/", registry=None
)
pc.load_registry(srcdir + "/" + registry_file)
with open(srcdir + "/" + registry_file) as fh:
for line in fh:
filename, hsum = line.split(" ")
pc.fetch(filename)
subprocess.run(["tar", "czf", f"{data_name}.tar.gz", data_name], check=True)