Skip to content

Commit

Permalink
hooks: add hooks for pypdfium2 and pypdfium2_raw
Browse files Browse the repository at this point in the history
Add hooks for `pypdfium2` (collect `version.json` file) and
`pypdfium2_raw` (collect `version.json` file and bundled pdfium
shared library).
  • Loading branch information
rokm committed Jan 25, 2025
1 parent e512683 commit 79828d1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2.py
Original file line number Diff line number Diff line change
@@ -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")
19 changes: 19 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-pypdfium2_raw.py
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions news/860.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hooks for ``pypdfium2`` and ``pypdfium2_raw``.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
""")

0 comments on commit 79828d1

Please sign in to comment.