dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Python
Expertise: Intermediate
Apr 17, 2004

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Creating a Python Executable File Using makeExe.py

This file creates an executable file from a Python file specified by the user and writes the new executable to disk.

"""
makeExe.py
- Simple Python script to automate the creation
  of Python executables using py2exe.

(c) 2004 Premshree Pillai (24/01/04) http://www.qiksearch.com/
"""

## Run this file from Python root dir

import sys
import re

def getFileName(): global fileName fileName = raw_input("Enter file name (rel or abs path, eg., python/file.py): ") try: fp = open(fileName) fp.close() except IOError: print "File does not exist!" getFileName()

getFileName()

package = re.split(":",fileName) package = re.split("/",package[len(package) - 1]) package = re.split(".py",package[len(package) - 1]) package = package[0]

def getSetupName(): global setupName setupName = raw_input( "Enter name of setup file (or for default): ") if(setupName == ''): setupName = "setup.py" try: fp = open(setupName) fp.close() flag = raw_input( "Setup file exists! Rewrite (0=no; else )? ") if(flag == "1"): getSetupName() except IOError: setupName = setupName

getSetupName()

fp = open(setupName,"w") temp = """from distutils.core import setup import py2exe setup(name = "%s", scripts = ["%s"], )""" % (package,fileName) fp.write(temp) fp.close()

sys.argv.append("py2exe") execfile(setupName)

fp = open(setupName,"w") temp = "" fp.write(temp) fp.close()

print "\n", "Executable created!" print "Press to exit..." if(raw_input()):exit

Premshree Pillai
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date