473,624 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Ente r file name (rel or abs
path, eg., python/file.py): ")

package = re.split(":",fi leName)
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,fileNa me)
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 1428
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,fileNa me)
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=pack age,
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
1180
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 http://www.qiksearch.com/] =====
0
1221
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 available at DevX: http://www.devx.com/opensource/Article/20247 -Premshree Pillai http://www.qiksearch.com/]
0
1301
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 complex and expensive because the response to any IT problem is to spend more money making things more complex." Robert X. Cringely on voting machines http://www.pbs.org/cringely/pulpit/pulpit20031204.html
0
1192
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 Executables Automatically" (http://www.devx.com/opensource/Article/20247/). -Premshree Pillai
6
1696
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 'easy-access' to the methods of the class. What is the best or typical directory structure that allows the easy creation of binary packages for linux and windows, source distributions, etc. Rather than make up my own way, I'd prefer to know if there is a
1
3652
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 "TypeError: unscriptable object.", but when I run my code normally (outside of trying to make an .exe), it runs perfectly. The dictionary doesn't have any data in it, until I call a method to grab some data from a file.
2
1235
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 the first exe. Can anyone show me the way to do that in c++ ? Thanks
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.