473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

makeExe.py

Wrote a simple Python script that makes life a wee bit
easier when using py2exe:

Also available at
http://premshree.resource-locator.com/python/makeExe.py

"""
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

fileName = raw_input("Enter file name (rel or abs
path, eg., python/file.py): ")

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

fp = open("setup.py","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("setup.py")

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

print "\n", "Executable created!"
print "Press <enter> to exit..."
if(raw_input()):
exit
=====
-Premshree
[http://www.qiksearch.com/]

__________________________________________________ ______________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com

Jul 18 '05 #1
3 1421
package = re.split("/",package[len(package) - 1])
package = re.split(".py",package[len(package) - 1])


You'll find the readability increases when using:

package = re.split("/", package[-1])
package = re.split(".py", package[-1])

Negative indices are your friends.
- Josiah
Jul 18 '05 #2
Hi !

And more : Negative indices are your Positive friends.
;-)

Jul 18 '05 #3
Premshree Pillai wrote:

Wrote a simple Python script that makes life a wee bit
easier when using py2exe:

"""
makeExe.py
- Simple Python script to automate the creation
of Python executables using py2exe.
[snip] fp = open("setup.py","w")
temp = """from distutils.core import setup
import py2exe
setup(name = "%s",
scripts = ["%s"],
)""" % (package,fileName)
fp.write(temp)
fp.close()


You could save yourself a fair bit of trouble, and avoid writing a
"setup.py" file to the filesystem (possibly overwriting an existing
one which might be important) by just calling the setup() method
directly yourself. The only trick is that it checks sys.argv[] for
the "py2exe" argument, so you have to fake that first:

sys.argv[1:] = ['py2exe']

from distutils.core import setup
setup(name=package,
scripts=[fileName])

That should do the trick.... if you're interested in integrating the
changes, and maintaining it, I'll forward our own script which you can
pull apart and reuse as required...

-Peter
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Premshree Pillai | last post by:
Made a few cosmetic changes to makeExe.py (limited error handling added). The modified source is available at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/266471 -Premshree Pillai...
0
by: Premshree Pillai | last post by:
Hey, For the uninitiated: an explanation of makeExe.py (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/266471), in the form of an article, “Create Python Executables Automatically”, is...
0
by: Cameron Laird | last post by:
QOTW: praise than which there is no higher: "I like the Python Cookbook, edited by Alex Martelli and David Ascher. I keep that one in my bathroom." Terry Carroll "e needed something more...
0
by: Premshree Pillai | last post by:
Hello, An explanation of makeExe.bat (http://premshree.resource-locator.com/j/post.php?id=152) has been appended to (http://www.devx.com/opensource/Article/20247/0/page/3) "Create Python...
6
by: baoilleach | last post by:
Dear all, Can anyone point me to a resource that describes the best way of organising a python project? My project (gausssum.sf.net) is based around a class, and has a GUI that allows...
1
by: kbperry | last post by:
Hi all, I am pretty confused on this? While pyinstaller has a "MakeCOMServer.py" thing, it seems to blow up every time I run it. It keeps complaining that a dictionary that I have has...
2
by: nemesisqp | last post by:
Hello, I see in a delphi program they make a application with a bunch of function that you can select by checkbox and a makeexe button, the exe generated will have only the function that selected in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.