This is possible. You need to search your hwid.exe in sys._MEIPASS
import sys
import os
import hashlib
def HWID_LIC():
if os.path.isfile('hwid.exe'):
print('file found in .')
else:
print('file not found in .')
if os.path.isfile(sys._MEIPASS + os.sep + 'hwid.exe'):
print('file found in sys._MEIPASS')
else:
print('file not found')
print(hashlib.md5(open(sys._MEIPASS + os.sep + 'hwid.exe', 'rb').read()).hexdigest())
if __name__ == '__main__':
HWID_LIC()
Example spec file:
# -*- mode: python -*-
a = Analysis(['test.py'],
pathex=[],
hiddenimports=[],
runtime_hooks=None)
import platform
if platform.system().find("Windows")>= 0:
a.datas = [i for i in a.datas if i[0].find('Include') < 0]
a.binaries = [x for x in a.binaries if not x[0].startswith("scipy")]
a.binaries = [x for x in a.binaries if not x[0].startswith("numpy")]
a.datas += [('hwid.exe','.\\hwid.exe','DATA'),]
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='test.exe',
debug=False,
strip=None,
clean=True,
upx=False,
console=True)
and create the onefile exe whith
pyinstaller t_onefile.spec
When executing test.exe you see:
j:\tmp>test.exe
file not found in .
file found in sys._MEIPASS
754222d71581010a45732c471437ecf7