Kat loves Mouse as Windows Linux |
I'm using Wine to make the exe with Pyinstaller. In addition to these, you'll have to install some tools to Wine's folder c_drive, in particular: Python, Pywin32, setuptools, and MS Visual C++. I'm using the pygame module myself, so that had to be put on there as well. Obviously, you want to download the tools which are compatible with Windows, and with the version of Python you're using. Use wine to install everything. Depending on the file extension, use the following commands to install all the components:
wine filename.exe
wine msiexec /i filename.msi
wine python filename.py
Due to the fact that Windows isn't case sensitive, Pyinstaller may be throwing the following warning at you: "WARNING: file already exists but should not: C:\Users\<name>\AppData\Local\Temp\_MEI34922\Include\pyconfig.h" You can bypass this by editing the file build.py, situated somewhere like: ~/.wine/drive_c/Python27/Lib/site-packages/PyInstaller-2.1-py2.7.egg/PyInstaller/build.py. Search for the function named "append" and change the line:
if tpl[2] == "BINARY:"to
if tpl[2] in ["BINARY","DATA"]:
At this point, you should be good to go. Once you've went through these steps once, whenever you need to chug out an exe, just cd to the directory where your main script is situated, and type:
wine pyinstaller --onefile main.py
This will put the executable in a folder named dist. You can safely rename this file and delete the build folder along with all python scripts before distributing your application.
A final note: Depending on your program, you may need to make small changes to the script to make everything work. In my own case, I'm using os.chdir() to access data files, starting from a "code" directory which I conveniently delete before distributing the exe. I worked around this by adding the following line at the top of my "main.py" script before running pyinstaller:
os.chdir(os.path.dirname(os.path.realpath(__file__))+'/graphics/')Happy hunting!
As always,
Minotauros