From 59092efb2f0c9b56d468920176bf50910dc81ae5 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Sat, 13 May 2023 20:05:49 +0200 Subject: [PATCH] Add hook for fastparquet --- news/583.new.rst | 1 + requirements-test-libraries.txt | 1 + .../hooks/stdhooks/hook-fastparquet.py | 32 +++++++++++++++++++ .../tests/test_libraries.py | 7 ++++ 4 files changed, 41 insertions(+) create mode 100644 news/583.new.rst create mode 100644 src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-fastparquet.py diff --git a/news/583.new.rst b/news/583.new.rst new file mode 100644 index 000000000..d3351f0d1 --- /dev/null +++ b/news/583.new.rst @@ -0,0 +1 @@ +Add hook for ``fastparquet``. \ No newline at end of file diff --git a/requirements-test-libraries.txt b/requirements-test-libraries.txt index c27f00586..59eeb8de1 100644 --- a/requirements-test-libraries.txt +++ b/requirements-test-libraries.txt @@ -125,6 +125,7 @@ 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' customtkinter==5.1.3 +fastparquet==2023.4.0 # ------------------- Platform (OS) specifics diff --git a/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-fastparquet.py b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-fastparquet.py new file mode 100644 index 000000000..9c8e9835f --- /dev/null +++ b/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-fastparquet.py @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------ +# 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 +# ------------------------------------------------------------------ +import os + +from PyInstaller.compat import is_win +from PyInstaller.utils.hooks import get_package_paths + +# In all versions for which fastparquet provides Windows wheels (>= 0.7.0), delvewheel is used, +# so we need to collect the external site-packages/fastparquet.libs directory. +if is_win: + pkg_base, pkg_dir = get_package_paths("fastparquet") + lib_dir = os.path.join(pkg_base, "fastparquet.libs") + if os.path.isdir(lib_dir): + # We collect DLLs as data files instead of binaries to suppress binary + # analysis, which would result in duplicates (because it collects a copy + # into the top-level directory instead of preserving the original layout). + # In addition to DLls, this also collects .load-order* file (required on + # python < 3.8), and ensures that fastparquet.libs directory exists (required + # on python >= 3.8 due to os.add_dll_directory call). + datas = [ + (os.path.join(lib_dir, lib_file), 'fastparquet.libs') + for lib_file in os.listdir(lib_dir) + ] diff --git a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py index 8f761f2e7..90befb771 100644 --- a/src/_pyinstaller_hooks_contrib/tests/test_libraries.py +++ b/src/_pyinstaller_hooks_contrib/tests/test_libraries.py @@ -1559,3 +1559,10 @@ def test_customtkinter(pyi_builder): pyi_builder.test_source(""" import customtkinter """) + + +@importorskip('fastparquet') +def test_fastparquet(pyi_builder): + pyi_builder.test_source(""" + import fastparquet + """)