Welcome, guest | Sign In | My Account | Store | Cart

script for making executables with py2exe

Python, 8 lines
1
2
3
4
5
6
7
8
from distutils.core import setup
import sys, os, py2exe

name = sys.argv[1]
sys.argv[1] = 'py2exe'
sys.path.append(os.path.dirname(os.path.abspath(name)))

setup(name=name[:-3], scripts=[name])

To eliminate the need to make setup.py for each python script which I about to convert to executable with py2exe, I wrote this simple script, and put it in my Tools/Scripts folder. Note, it cannot be named "py2exe.py" as it asks, because it imports py2exe. Now for any of my scripts I simply run "pyexe.py myscript.py", and get distribution in dist/myscript folder.