Skip to content

Commit

Permalink
hooks: add hook for numbers_parser
Browse files Browse the repository at this point in the history
Add hook for `numbers_parser` to ensure that the package's data
file (`numbers_parser/data/empty.numbers`) is collected.
  • Loading branch information
rokm committed Oct 22, 2024
1 parent 8374416 commit d4f1599
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-numbers_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ------------------------------------------------------------------
# Copyright (c) 2024 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

# Ensure that `numbers_parser/data/empty.numbers` is collected.
datas = collect_data_files('numbers_parser')
2 changes: 2 additions & 0 deletions news/823.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add hook for ``numbers_parser`` to ensure that package's data file is
collected.
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ xmlschema==3.4.1
pysaml2==7.5.0; python_version >= '3.9'
pysaml2==7.3.0; python_version < '3.9' # pyup: ignore
toga==0.4.8; python_version >= '3.9'
numbers-parser==4.14.1; python_version >= '3.9'

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

Expand Down
20 changes: 20 additions & 0 deletions tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2262,3 +2262,23 @@ def test_toga(pyi_builder):
app_args=['--automatic-shutdown', '5'],
pyi_args=['--windowed'] if is_darwin else [],
)


@importorskip('numbers_parser')
def test_numbers_parser(pyi_builder, tmpdir):
output_filename = tmpdir / "output.numbers"
pyi_builder.test_source("""
import sys
import numbers_parser
output_filename = sys.argv[1]
doc = numbers_parser.Document()
doc.add_sheet("New Sheet", "New Table")
sheet = doc.sheets["New Sheet"]
table = sheet.tables["New Table"]
table.write(1, 1, 1000)
table.write(1, 2, 2000)
table.write(1, 3, 3000)
doc.save(output_filename)
""", app_args=[str(output_filename)])

0 comments on commit d4f1599

Please sign in to comment.