add pyinstaller hook

This commit is contained in:
duncathan 2021-12-08 00:12:16 -06:00
parent 46f7d13f70
commit 42f4e74c85
4 changed files with 51 additions and 0 deletions

10
pre_edited_cs/__init__.py Normal file
View file

@ -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

View file

@ -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 <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__)]

View file

@ -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'])

View file

@ -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
# <https://pyinstaller.readthedocs.io/en/stable/usage.html#what-to-bundle-where-to-search>`_
# 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