Skip to content

Commit

Permalink
Add hook for librosa
Browse files Browse the repository at this point in the history
  • Loading branch information
rokm committed May 13, 2023
1 parent 30cf5e2 commit 6708c44
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ NBT==1.5.1
minecraft-launcher-lib==5.3; python_version >= '3.8'
scikit-learn==1.2.2; python_version >= '3.8'
scikit-image==0.20.0; python_version >= '3.8'
librosa==0.10.0.post2

# ------------------- Platform (OS) specifics

Expand Down
22 changes: 22 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-librosa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ------------------------------------------------------------------
# Copyright (c) 2023 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files, collect_submodules

# Collect all data files from the package. These include:
# - package's and subpackages' .pyi files for `lazy_loader`
# - example data in librosa/util, required by `librosa.util.files`
# - librosa/core/intervals.msgpack, required by `librosa.core.intervals`
datas = collect_data_files("librosa", excludes=['**/__pycache__'])

# And because modules are lazily loaded, we need to collect them all.
hiddenimports = collect_submodules("librosa")
13 changes: 13 additions & 0 deletions src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1552,3 +1552,16 @@ def test_moviepy_editor(pyi_builder):
pyi_builder.test_source("""
import moviepy.editor
""")


@importorskip('librosa')
def test_librosa(pyi_builder):
pyi_builder.test_source("""
import librosa
# Requires intervals.msgpack data file
import librosa.core.intervals
# Requires example files on import
import librosa.util.files
""")

0 comments on commit 6708c44

Please sign in to comment.