I am trying to generate one .exe file with pyinstaller
my python file
import subprocess
proc=r".\file.exe"
CLI_VERSION=subprocess.check_output([proc, '-v'],shell=True).decode('utf-8').strip()
print (CLI_VERSION)
with file.exe being in the same folder as the python file
python myfile.py
works just fine and prints the expected output
Now when I try to package that as .exe and include file.exe, subprocess still fails to find the file
pyinstaller.exe --onefile --add-data ".\file.exe;." .\myfile.py
now take the generated.exe and try to run it:
.\file.exe' is not recognized as an internal or external command, ... ... ... subprocess.CalledProcessError: Command '['.\file.exe', '-v']' returned non-zero exit status 1.
I tried add-binary instead of add-data since this is an exe file but it is still not working. Please note that the file.exe always returns 0, if it is called properly.
I am assuming this has to do with how subprocess works? is there a way to get it to work?
Is there a way to list files included in the .exe package? Judging by the filesize variation, I think the file.exe has been added, but I believe subprocess access the filesystem directly without passing by the files included in .exe package, is that the case?
I tried to do add-data for some files then inside the python file do "dir" (ls equivalent of ls) I don't see the files I included with --add-data
in the list
Edit: I unpackaged the generated .exe using pyinstxtractor. The outcome is that my file.exe is well included in the same place as the name_of_my_python_file.pyc in the extracted package.
This makes me believe more in my theory: subprocess accesses the filesystem directly and does not read inside the packaged data. Does anyone have the knowledge to confirm and suggest a workaround (if possible)?
Thanks