From 79828d1b1e89966d3ad603e408d3c8c64fb41e33 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Sat, 25 Jan 2025 16:48:25 +0100 Subject: [PATCH] hooks: add hooks for pypdfium2 and pypdfium2_raw Add hooks for `pypdfium2` (collect `version.json` file) and `pypdfium2_raw` (collect `version.json` file and bundled pdfium shared library). --- .../stdhooks/hook-pypdfium2.py | 16 ++++++++++++++++ .../stdhooks/hook-pypdfium2_raw.py | 19 +++++++++++++++++++ news/860.new.rst | 1 + requirements-test-libraries.txt | 1 + tests/test_libraries.py | 7 +++++++ 5 files changed, 44 insertions(+) create mode 100644 _pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2.py create mode 100644 _pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2_raw.py create mode 100644 news/860.new.rst diff --git a/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2.py b/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2.py new file mode 100644 index 00000000..1005a8bb --- /dev/null +++ b/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------ +# Copyright (c) 2025 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, distributed with +# this software. +# +# SPDX-License-Identifier: GPL-2.0-or-later +# ------------------------------------------------------------------ + +from PyInstaller.utils.hooks import collect_data_files + +# Collect `version.json`. +datas = collect_data_files("pypdfium2") diff --git a/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2_raw.py b/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2_raw.py new file mode 100644 index 00000000..01a349d0 --- /dev/null +++ b/_pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2_raw.py @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------ +# Copyright (c) 2025 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, distributed with +# this software. +# +# SPDX-License-Identifier: GPL-2.0-or-later +# ------------------------------------------------------------------ + +from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files + +# Collect the bundled pdfium shared library. +binaries = collect_dynamic_libs('pypdfium2_raw') + +# Collect `version.json`. +datas = collect_data_files("pypdfium2_raw") diff --git a/news/860.new.rst b/news/860.new.rst new file mode 100644 index 00000000..f44da607 --- /dev/null +++ b/news/860.new.rst @@ -0,0 +1 @@ +Add hooks for ``pypdfium2`` and ``pypdfium2_raw``. diff --git a/requirements-test-libraries.txt b/requirements-test-libraries.txt index c4015cc4..774c33ab 100644 --- a/requirements-test-libraries.txt +++ b/requirements-test-libraries.txt @@ -82,6 +82,7 @@ pyexcelerate==0.12.0 pyexcel_ods==0.6.0 pylibmagic==0.5.0; sys_platform != 'win32' pylint==3.3.3; python_version >= '3.9' +pypdfium2==4.30.1 pypemicro==0.1.11 pyphen==0.17.0; python_version >= '3.9' pyppeteer==2.0.0 diff --git a/tests/test_libraries.py b/tests/test_libraries.py index 1fca5625..c058ea22 100644 --- a/tests/test_libraries.py +++ b/tests/test_libraries.py @@ -2546,3 +2546,10 @@ def test_ruamel_yaml_string_plugin(pyi_builder): data = dict(abc=42, help=['on', 'its', 'way']) print(yaml.dump_to_string(data)) """) + + +@importorskip('pypdfium2') +def test_pypdfium2(pyi_builder): + pyi_builder.test_source(""" + import pypdfium2 + """)