3
votes

I have had success using pyInstaller 2.0 to create executables from simple python scripts. I have a python script which runs different searches and produces different output based on command line arguments. Is there a way to use pyInstaller to create an executable of the script assuming certain arguments? As in, I want to produce an exe file that will run and produce the same output as if I were to run it from the command line as follows:

python pacman.py --layout mediumMaze --pacman SearchAgent

Is this possible with pyInstaller 2.0? I have not been able to find this addressed in the provided manual. Thank you in advance.

1
Edit pacman.py to assume these arguments as default? - user395760

1 Answers

1
votes

This is sort of a roundabout way to do it, but you could import pacman.py in a separate python file, and call it in such a way that it does the things the command line arguments specify. Then, using pyinstaller, you would compile the separate python file.

If it's not possible to use pacman.py in that manner, you could try creating the following Python file and letting pyinstaller compile that.

import sys

sys.argv.extend(['--layout', 'mediumMaze', '--pacman', 'SearchAgent'])

import pacman
pacman.main() # if your file has a `main` function

(In both cases, pyinstaller would still combine the two files together into one exe)