:fwi.py
def res_path(cpath):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path,cpath)
[unpack mode]
res_path("app") => Show the current path with app program
ex. /opt/app
[After pack]
res_path("app") => show the _MEIPASS folder path with app program
ex. /tmp/_MEIPASS/app
PS: You must used res_path function with fulled path in your python code. If you want to pack your python code.
Add your data files into fwi.spec files
:fwi.spec
+ a.datas = [('smartctl','./source/smartctl','DATA'),('hdparm','./source/hdparm','DATA')]
Pack by pyinstaller:
python pyinstaller.py --onefile fwi.spec