thmahe / poetry-pyinstaller-plugin

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

How to add data files #10

Closed Sigurdur42 closed 3 months ago

Sigurdur42 commented 3 months ago

Hi, I am trying to add data files, especially a QT ui file. I use this in the toml file:

[tool.poetry-pyinstaller-plugin.collect]
data = ['clock.png', 'MainWindow.ui']

Unfortuantely, I cannot see the MainWindow.ui file anywhere in the dist folder and therefore I cannot load it at runtime. How do I achieve having the file in the correct location? Thx

thmahe commented 3 months ago

Hi @Sigurdur42,

tool.poetry-pyinstaller-plugin.collect options only accept packages as input. Those options are useful to include package data from dependencies onto Pyinstaller executable or dist folder.

You can include data to your package with following option in [tool.poetry] block of your pyproject.toml:

include = [
    { path = "clock.png", format = ["sdist", "wheel"] },
    { path = "MainWindow.ui", format = ["sdist", "wheel"] }
]

poetry-pyinstaller-plugin does not support yet addition of data files from include option.

You can instead use the bundle feature to include your Pyinstaller executable onto wheels built by Poetry which will also include your data files with method above.