-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a PyInstaller hook and a test to verify it works
- Loading branch information
Showing
6 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import os | ||
|
||
|
||
def get_hook_dirs(): | ||
return [os.path.dirname(__file__)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from PyInstaller.utils.hooks import collect_data_files | ||
|
||
datas = collect_data_files("isocodes") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import subprocess | ||
|
||
from PyInstaller import __main__ as pyi_main | ||
import textwrap | ||
import pathlib | ||
|
||
|
||
# Tests | ||
# ===== | ||
# Test out the package by importing it, then running functions from it. | ||
def test_pyi_isocodes(tmp_path: pathlib.Path) -> None: | ||
app_name = "isocodes_pyinstaller" | ||
workpath = tmp_path / "build" | ||
distpath = tmp_path / "dist" | ||
app = tmp_path / (f"{app_name}.py") | ||
|
||
app.write_text( | ||
textwrap.dedent( | ||
""" | ||
import isocodes | ||
assert isocodes.languages.get(name='Spanish') | ||
""" | ||
) | ||
) | ||
args = [ | ||
# Place all generated files in ``tmp_path``. | ||
"--workpath", | ||
str(workpath), | ||
"--distpath", | ||
str(distpath), | ||
"--specpath", | ||
str(tmp_path), | ||
str(app), | ||
] | ||
pyi_main.run(args) | ||
subprocess.run([str(distpath / app_name / app_name)], check=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
[tox] | ||
skipsdist = true | ||
envlist = py38, py39, py310, py311, py312 | ||
|
||
[testenv] | ||
|