Hi, I created a basic pyinstaller tool to automate the creation process. I want to post it as more of an idea than anything for people to extend, modify, or create their own tool similar to this. It certainly made my development a good bit quicker and easier. Without further adieu, here is the code. It is fairly small as it is a basic idea.
#!/usr/bin/python ##This script is under the standard open-source license (Whatever that entails). ##Please never try to sell this software. If you would like for some reason ##to include it in a software package that you sell or give out that would be ##okay though. I just want it to be used by whomever it may help out a bit. ##This script was created by Keith Brandenburg. You may email me at [email protected] ##for comments or suggestions. It was an idea I got after creating my first exe with ##Pyinstaller-1.3 and I thought that the creation process was a little lengthy so I ##made this script to automate it a bit for me. So I sent it to the Pyinstaller website ##just in case it may be useful to other Pyinstaller users. ##This script is intended to shorten your executable creation process considerably ##by doing all the Makespec and Build commands for you. All you should have to do ##is give the path of the script and where you want it to end up. ##This will only work on one script at a time but feel free to alter the script ##to tailor to your needs if you would like. Also this script obviously only runs on linux. ##But if you look at it just a tiny bit you could easily create a similar script to run ##on windows. I may make one just for the fun of it. :) import os print "\nThis script works with Pyinstaller1.3. Not sure if it works with other versions or not."; print "Edit the script as needed to make it work.\n\n"; ##This loop will attempt to open the config file. If it does not exist it will create it and ask you ##for the path of your Pyinstaller installation. Then it tests to see if the path is correct and ##writes the path to the config file if it is a correct path to pyinstaller. while True: try: configfile = open('.pyconfig', 'r'); pyinstallerpath = configfile.read(); pyinstallerpath = pyinstallerpath.rstrip(); configfile.close(); break; except IOError: configfile = open('.pyconfig', 'w'); pyinstallerpath = raw_input(""" What is the path of your pyinstaller? Answer in the form of /my/path/to/pyinstaller-x.x/ Path: """); try: testdirectory = open(pyinstallerpath + 'Build.py', 'r') testdirectory.close(); configfile.write(pyinstallerpath); pyinstallerpath = pyinstallerpath.rstrip(); configfile.close(); break; except IOError: print "Invalid Path. Be sure to include the last '/' at"; print "the end of the path you entered."; print "It also does not accept shortcuts like ~/ home/"; print "You must give a full path like /root/home/ pyinstaller-x.x/\n\n"; os.remove('.pyconfig'); continue; ##This little loop just gets a path to a script for us to create an executable out of ##and tests the file by trying to open it in read mode. If the file exists it will work. ##If the file does not open then it will ask the user to input the path again. (ideally) while True: try: scriptpath = raw_input("Enter script with full path: "); script = open(scriptpath, 'r'); script.close() break; except IOError: print "File %s doesn't exist" % (scriptpath); ##Gets the path the user wants the executable to be located after script is finished and the name of the exe. destination = raw_input("Name of executable (including path) to create: "); ##command that creates spec file with --onefile or -F option in the / tmp/createtemp/ directory with name "build" makespeccommand = "python " + pyinstallerpath + "Makespec.py -F --out=/ tmp/createtemp/ -n build %s" % (scriptpath) ##command that runs Build.py on the created spec file makeexecommand = "python " + pyinstallerpath + "Build.py /tmp/ createtemp/build.spec" ##command that moves and renames the Built exe file to the specified destination of the user mvexecommand = "mv /tmp/createtemp/build %s" % (destination) ##deletes the created /tmp/createtemp directory cleanup = "rm -r /tmp/createtemp*" ##creates our /tmp/createtemp directory for our work to be done in. os.mkdir('/tmp/createtemp') os.system(makespeccommand) ##these system commands simply os.system(makeexecommand) ##run the commands that were os.system(mvexecommand) ##created above. Alter the os.system(cleanup) ##commands above as needed --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "PyInstaller" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pyinstaller?hl=en -~----------~----~----~----~------~----~------~--~---
