Skip to content

Commit

Permalink
Merge pull request #284 from lordwelch/pyinstaller
Browse files Browse the repository at this point in the history
Pyinstaller
  • Loading branch information
Atem Serem authored Nov 26, 2023
2 parents 5ee670a + ac213ea commit b923378
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 6 deletions.
5 changes: 5 additions & 0 deletions isocodes/__pyinstaller/__init__.py
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__)]
3 changes: 3 additions & 0 deletions isocodes/__pyinstaller/hook-isocodes.py
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")
36 changes: 36 additions & 0 deletions isocodes/__pyinstaller/test_pyinstaller.py
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)
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ dev = ["pre-commit == 3.5.0", "ruff == 0.1.6", "mypy == 1.7.0"]

doc = ["mkdocs == 1.5.3", "mkdocs-material == 9.4.11", "mkdocstrings == 0.23.0"]

test = ["pytest == 7.4.3", "tox == 4.11.3"]
test = ["pytest == 7.4.3", "tox == 4.11.3", "pyinstaller[hook_testing] == 6.2.0", "psutil == 5.9.6"]

build = ["hatch == 1.7.0"]

[project.entry-points.pyinstaller40]
hook-dirs = "isocodes.__pyinstaller:get_hook_dirs"
tests = "isocodes.__pyinstaller:get_hook_dirs"
21 changes: 17 additions & 4 deletions requirements/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=test --output-file=requirements/test-requirements.txt --resolver=backtracking pyproject.toml
# pip-compile --extra=test --output-file=requirements/test-requirements.txt pyproject.toml
#
attrs==23.1.0
# via pytest
altgraph==0.17.4
# via
# macholib
# pyinstaller
cachetools==5.3.1
# via tox
chardet==5.2.0
Expand All @@ -14,16 +16,19 @@ colorama==0.4.6
# via tox
distlib==0.3.7
# via virtualenv
exceptiongroup==1.1.3
exceptiongroup==1.2.0
# via pytest
filelock==3.12.4
# via
# tox
# virtualenv
iniconfig==2.0.0
# via pytest
macholib==1.16.3
# via pyinstaller
packaging==23.2
# via
# pyinstaller
# pyproject-api
# pytest
# tox
Expand All @@ -35,6 +40,14 @@ pluggy==1.3.0
# via
# pytest
# tox
psutil==5.9.6
# via isocodes (pyproject.toml)
pyinstaller[hook-testing]==6.2.0
# via
# isocodes (pyproject.toml)
# pyinstaller
pyinstaller-hooks-contrib==2023.10
# via pyinstaller
pyproject-api==1.6.1
# via tox
pytest==7.4.3
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[tox]
skipsdist = true
envlist = py38, py39, py310, py311, py312

[testenv]
Expand Down

0 comments on commit b923378

Please sign in to comment.