thmahe / poetry-pyinstaller-plugin

Poetry plugin to build and/or bundle binaries with PyInstaller
https://pypi.org/project/poetry-pyinstaller-plugin/
MIT License
12 stars 6 forks source link

Add support for tool.poetry.include #13

Closed Nealium closed 1 week ago

Nealium commented 1 week ago

Closes #10 and added pipx inject install method to README as self add "may be problematic" 🤷

Development flow with pipx:

# install 
pipx runpip poetry install dist/{some_wheel}.whl

# uninstall
pipx runpip poetry uninstall poetry-pyinstaller-plugin

Edit

I've kept it as two commits in case a roll back needs to happen. I didn't want to make two pull requests as "extended_includes" requires "includes"

include_extended explained

The problem with a 1-1 with Poetry's include is that:

  1. You cannot include directories, It will loosely place files into _internal
  2. You cannot put files next to the pyinstaller executable. A included README would be placed into _internal and with a onefile install it would be worse than useless.
  3. You cannot rename files. Ex: ENDUSER_README.md -> README.md

To add this functionality I've added three new settings:

  1. [poetry-pyinstaller-plugin.exclude-include] (boolean=false)
    • disables plugin's features for base poetry.include packing
  2. [poetry-pyinstaller-plugin.include] (dict[source, destination])
    • a 1-1 mapping for --add-data
    • allows for destination renaming
    • allows for entire directories to be copied
  3. [poetry-pyinstaller-plugin.package] (dict[source, destination])
    • adds the ability to place files or directories next to the pyinstaller executable
    • destination renaming

[poetry-pyinstaller-plugin.package] caveat

It doesn't support creating nested destinations.

Example:

This does not work:

[tool.poetry-pyinstaller-plugin.package]
"README.md" = "docs/README.md"  # docs directory doesn't exist!

This does work:

[tool.poetry-pyinstaller-plugin.package]
"docs" = "."                    # create directory
"README.md" = "docs/README.md"  # place into directory