flit
flit copied to clipboard
Runtime dependencies
Hello everyone,
I hope I am using the right terms here, but what I want is to ship a little piece of 'data', an icon.png
(14kB), with my package pyBOAT. It has a GUI, so when users launch the application it would be nice to show something descriptive in the task switchers etc. On PyPI under 'Download Files' I get indeed everything, however after a pip or conda install I can't locate the icon.png
in the respective site-packages
directory. Hence my application can't load/show the icon. How can I bundle a little file (icon.png in my case) with the source using flit?
Thx in advance!
In general, if you want to ship a data file which the code uses, put it inside the package (with your Python code), and find it either with a relative path from __file__
, or with importlib.resources if you're only supporting Python 3.7+.
Yes of course (facepalming), the obvious solution worked!
I am retrieving the icon location with
abs_path = os.path.dirname(os.path.realpath(__file__))
icon_path = os.path.join(abs_path, 'logo_circ128x128.png')
et voila :) Thanks for your quick reply!
No problem. I'll leave this open as a docs request, because it's only easy if you know about __file__
.