From 42f4e74c8590d0c89f57437e2c9793d7d16b798e Mon Sep 17 00:00:00 2001 From: duncathan Date: Wed, 8 Dec 2021 00:12:16 -0600 Subject: [PATCH] add pyinstaller hook --- pre_edited_cs/__init__.py | 10 ++++++++++ pre_edited_cs/__pyinstaller/__init__.py | 18 ++++++++++++++++++ .../__pyinstaller/hook-pre-edited-cs.py | 5 +++++ setup.cfg | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 pre_edited_cs/__init__.py create mode 100644 pre_edited_cs/__pyinstaller/__init__.py create mode 100644 pre_edited_cs/__pyinstaller/hook-pre-edited-cs.py diff --git a/pre_edited_cs/__init__.py b/pre_edited_cs/__init__.py new file mode 100644 index 0000000..5784c3a --- /dev/null +++ b/pre_edited_cs/__init__.py @@ -0,0 +1,10 @@ +import sys +from pathlib import Path + + +def get_path() -> Path: + if getattr(sys, "frozen", False): + file_dir = Path(getattr(sys, "_MEIPASS")) + else: + file_dir = Path(__file__).parent + return file_dir diff --git a/pre_edited_cs/__pyinstaller/__init__.py b/pre_edited_cs/__pyinstaller/__init__.py new file mode 100644 index 0000000..aefa2e0 --- /dev/null +++ b/pre_edited_cs/__pyinstaller/__init__.py @@ -0,0 +1,18 @@ +import os + + +# Functions +# ========= +# +# .. _get_hook_dirs: +# +# get_hook_dirs +# ------------- +# +# Tell PyInstaller where to find hooks provided by this distribution; +# this is referenced by the :ref:`hook registration `. +# This function returns a list containing only the path to this +# directory, which is the location of these hooks. + +def get_hook_dirs(): + return [os.path.dirname(__file__)] \ No newline at end of file diff --git a/pre_edited_cs/__pyinstaller/hook-pre-edited-cs.py b/pre_edited_cs/__pyinstaller/hook-pre-edited-cs.py new file mode 100644 index 0000000..a6387ab --- /dev/null +++ b/pre_edited_cs/__pyinstaller/hook-pre-edited-cs.py @@ -0,0 +1,5 @@ +from PyInstaller.utils.hooks import collect_data_files + +# https://pyinstaller.readthedocs.io/en/stable/hooks.html#provide-hooks-with-package + +datas = collect_data_files('pre_edited_cs', excludes=['__pyinstaller']) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 9aff60c..15832e3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,3 +21,21 @@ install_requires = include_package_data = True zip_safe = False python_requires = >=3.9 + +# +# Entry Points for PyInstaller +# --------------------------------- +[options.entry_points] +pyinstaller40 = + # .. _hook_registration: + # + # **Hook registration**: This entry point refers to a function + # that will be invoked with no parameters. It must return a + # sequence of strings, each element of which provides an + # additional absolute path to search for hooks. This is equivalent + # to passing the ``additional-hooks-dir`` `command-line option + # `_ + # to PyInstaller for each string in the sequence. + # + # In this project, the function is ``get_hook_dirs``. + hook-dirs = pre_edited_cs.__pyinstaller:get_hook_dirs \ No newline at end of file