Re: py2exe (setup.py) for pythoncard apps
Phil Edwards <[email protected]> Tue, 20 Nov 2007 09:46:29 +0000
| Newsgroups | gmane.comp.python.pythoncard |
|---|---|
| Message-ID | <[email protected]> |
Tony Cappellini wrote: > I've used py2exe for several command-line apps before, but not for a > Pythoncard app. > > Would someone post the contents of setup.py for a Pythoncard app? > > How do you get py2exe to put the script.rsrc.py file inside the .exe ? > Hi Tony: Take a look at the standaloneBuilder tool which comes with the PythonCard distribution. My brief notes on the process of converting PythonCard apps to executables can be found here: http://pythoncard.sourceforge.net/standalone.html Although this is based around using pyInstaller, the standaloneBuilder app supports py2exe as well. I've attached copies of the setup.py and associated data files that standaloneBuilder generates for a py2exe build, hope this helps. Essentially, the resource files stay as they are, i.e. they don't get packed into the EXE in any way. I've often thought it would be useful to write some sort of helper class which would allow resource files to be bundled up into a module that the app could import, along similar lines to the img2py stuff which comes with the wxPython demo. -- Regards Phil Edwards Brighton, UK ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Pythoncard-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pythoncard-users
setup.py
(text/x-python, 2.2 KB)
#!/usr/bin/python # # generic py2exe setup script - Phil Edwards <[email protected]> # Copyright (c) 2001-2005 PythonCard developers # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY # WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # vim: ai et sw=4 ts=4 from distutils.core import setup import py2exe data_files = eval((open('datafiles.dat').read())) standalone = eval((open('standalone.dat').read())) buildOpts = eval((open('buildoptions.dat').read())) buildType = buildOpts['buildType'] if buildOpts.has_key('singlefile'): options = {"py2exe": {"compressed": 1, "optimize": 2, "bundle_files": 1, "ascii": 1}} zipfile = None else: options = {"py2exe": {"compressed": 1, "optimize": 2}} zipfile = r"lib/sharedlib" print options if buildType != "windows": setup(options = options, zipfile = zipfile, data_files = data_files, console = [standalone]) else: setup(options = options, zipfile = zipfile, data_files = data_files, windows = [standalone])
buildoptions.dat
(text/plain, 25 B)
{'buildType': 'windows'}
datafiles.dat
(text/plain, 2.2 KB)
[('.',
['buildDialog.rsrc.py',
'helpAbout.gtk.rsrc.py',
'helpAbout.rsrc.py',
'helpManual.rsrc.py',
'newProjectWizard.gtk.rsrc.py',
'newProjectWizard.rsrc.py',
'newProjectWizardPage1.gtk.rsrc.py',
'newProjectWizardPage1.rsrc.py',
'newProjectWizardPage2.gtk.rsrc.py',
'newProjectWizardPage2.rsrc.py',
'newProjectWizardPage3.gtk.rsrc.py',
'newProjectWizardPage3.rsrc.py',
'newProjectWizardPage4.gtk.rsrc.py',
'newProjectWizardPage4.rsrc.py',
'outputWindow.gtk.rsrc.py',
'outputWindow.rsrc.py',
'prefsDialog.gtk.rsrc.py',
'prefsDialog.rsrc.py',
'propertiesDialog.gtk.rsrc.py',
'propertiesDialog.rsrc.py',
'standaloneBuilder.gtk.rsrc.py',
'standaloneBuilder.rsrc.py',
'versionDialog.rsrc.py',
'changelog.txt',
'readme.txt']),
('pixmaps',
['pixmaps\\apollon.ico',
'pixmaps\\blank.png',
'pixmaps\\changelog.png',
'pixmaps\\exit.png',
'pixmaps\\inno.png',
'pixmaps\\manual.png',
'pixmaps\\new.png',
'pixmaps\\newproject.png',
'pixmaps\\open.png',
'pixmaps\\prefs.png',
'pixmaps\\props.png',
'pixmaps\\readme.png',
'pixmaps\\rebuild.png',
'pixmaps\\release.png',
'pixmaps\\run.png',
'pixmaps\\save.png',
'pixmaps\\spec.png',
'pixmaps\\apollon.png']),
('templates',
['templates\\about.html',
'templates\\author.html',
'templates\\changelog.txt',
'templates\\gpl.html',
'templates\\gpl.txt',
'templates\\manifest.txt',
'templates\\readme.txt',
'templates\\setup.py',
'templates\\versioninfo.txt']),
('doc',
['doc\\about.html',
'doc\\author.html',
'doc\\license.html',
'doc\\license.txt',
'doc\\pic1.jpg',
'doc\\pic10.jpg',
'doc\\pic11.jpg',
'doc\\pic12.jpg',
'doc\\pic13.jpg',
'doc\\pic14.jpg',
'doc\\pic15.jpg',
'doc\\pic16.jpg',
'doc\\pic17.jpg',
'doc\\pic18.jpg',
'doc\\pic19.jpg',
'doc\\pic2.jpg',
'doc\\pic20.jpg',
'doc\\pic21.jpg',
'doc\\pic22.jpg',
'doc\\pic23.jpg',
'doc\\pic24.jpg',
'doc\\pic25.jpg',
'doc\\pic26.jpg',
'doc\\pic27.jpg',
'doc\\pic28.jpg',
'doc\\pic29.jpg',
'doc\\pic3.jpg',
'doc\\pic4.jpg',
'doc\\pic5.jpg',
'doc\\pic6.jpg',
'doc\\pic7.jpg',
'doc\\pic8.jpg',
'doc\\pic9.jpg',
'doc\\standaloneBuilder.html'])]
standalone.dat
(text/plain, 120 B)
{'dest_base': 'standaloneBuilder',
'icon_resources': [(1, 'pixmaps\\apollon.ico')],
'script': 'standaloneBuilder.py'}