Skip to content

Add a hook to ease integration with pyinstaller #193

@enlivn

Description

@enlivn

What did you do?

A developer that wishes to use this library with pyinstaller must explicitly tell pyinstaller to retain the translation files for the library. One way to do this if you're using pyinstaller spec files is:

import os
from PyInstaller.utils.hooks import collect_all

spec_parent_directory = f"{os.path.abspath(SPECPATH)}/.."

main_app_datas = []
main_app_binaries = []
main_app_hiddenimports = []
tmp_ret = collect_all('humanize')
main_app_datas += tmp_ret[0]
main_app_binaries += tmp_ret[1]
main_app_hiddenimports += tmp_ret[2]

main_app_analysis = Analysis(
    [f'{spec_parent_directory}/app_entry_point.py'],
    pathex=[f'{spec_parent_directory}'],
    binaries=main_app_binaries,
    datas=main_app_datas,
    hiddenimports=main_app_hiddenimports
)

To reduce this overhead, pyinstaller allows packages to provide a hook that pyinstaller can then leverage.

Here is the documentation on pyinstaller hooks.
Here is a sample library that shows how to add a custom hook.

We could either update this library to provide a hook or perhaps update the README (or some other markdown file) to provide the code snippet above that any dev that encounters this in the future can use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions