#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    py2exe explain please


    I am having problem unterstanding py2exe can someone give me a simple programme converts to exe ?

    Thanks in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    30
    Rep Power
    0
    found this.

    Code:
    """
    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
    
    #function getFileName()
    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()
    
    #call function
    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 <enter> for default): ")
    	if(setupName == ''):
    		setupName = "setup.py"
    	try:
    		fp = open(setupName)
    		fp.close()
    		flag = raw_input("Setup file exists! Rewrite (0=no; else <enter>)? ")
    		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 <enter> to exit..."
    if(raw_input()):
    	exit
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    12
    Rep Power
    0
    Hi - tried the above - and it seems to run without error, but am having problems finding the created executable....

    Any help appreciated....
    Last edited by adavidso; May 6th, 2004 at 12:38 PM.

IMN logo majestic logo threadwatch logo seochat tools logo