sorry, I didn't refresh my browser page before I sent that last
e-mail. Glad to see it worked!
Yeah, the data isn't automatically copied, that's why I specified that I had to copy my data over. You can easily write a script that will copy your data over, using os functions, or shutil, or something. That would be a question for the tutor@xxxxxxxxxx mailing list. Hi Luke,
That is OK, I also downloaded
that one skeleton form from that other game and that is below. It was something
someone else mentioned to me to do. I also had modified that other batch file as
well.
The only modification I had made
to it was to delete or comment out I mean, the references to the Windows
command. I am using only the console for now because I am totally blind and the
screen for Pygame is not screen reader friendly at the moment.
So I just added the console
command instead and all works fine. Transports over my data file and all the
sound files. The interesting error I was getting in the Windows command was from
the raw_input command and where ever I had placed it. So I figured out quickly
what was going on and got rid of the windows reference...
So now I can compile my game and
have it all inside the dist folder. Now to have it all zipped up immediately as
well.
Also, in this file below there
needs to be added the statement to not load all files that are not needed. I get
a lot of stuff in this file that I did not get in the other one. In other words
I get everything and probably do not need most of it. The dist folder ends up
being 29 megs...
Any suggestions would be
helpful!
Luke, if you want to have this
skeleton form here is that setup.py file I am using and the commented out
windows and reference to the icon.ico...
Using: python25 setup.py py2exe
Setup.py File:
APP_NAME = 'Trek_Game' cfg = { 'name':APP_NAME, 'version':'1.0', 'description':'', 'author':'', 'author_email':'', 'url':'', 'py2exe.target':'', # 'py2exe.icon':'icon.ico', #64x64 'py2exe.binary':APP_NAME, #leave off the .exe, it will be added 'py2app.target':'', 'py2app.icon':'icon.icns', #128x128 'cx_freeze.cmd':'~/src/cx_Freeze-3.0.3/FreezePython', 'cx_freeze.target':'', 'cx_freeze.binary':APP_NAME, } # usage: python setup.py command # # sdist - build a source dist # py2exe - build an exe # py2app - build an app # cx_freeze - build a linux binary (not implemented) # # the goods are placed in the dist dir for you to .zip up or whatever... from distutils.core import setup, Extension
try: import py2exe except: pass import sys
import glob import os import shutil try:
cmd = sys.argv[1] except IndexError: print 'Usage: setup.py py2exe|py2app|cx_freeze' raise SystemExit # utility for adding subdirectories
def add_files( dest, generator): for dirpath, dirnames, filenames in generator: for name in 'CVS', '.svn': if name in dirnames: dirnames.remove(name) for name in
filenames:
if '~' in name: continue suffix = os.path.splitext(name)[1] if suffix in ('.pyc', '.pyo'): continue if name[0] == '.': continue filename = os.path.join(dirpath, name) dest.append(filename) # define what is our data
data = "">add_files( data, os.walk('data')) data.extend( glob.glob('*.txt')) # define what is our source src = "">add_files( src, os.walk('lib')) src.extend( glob.glob('*.py')) # build the sdist target
if cmd == 'sdist': f = open( "MANIFEST.in", "w") for l in data: f.write("include "+l+"\n") for l in src: f.write("include "+l+"\n") f.close() setup( name=cfg['name'], version=cfg['version'], description=cfg['description'], author=cfg['author'], author_email=cfg['author_email'], url=""> ) # build the py2exe target
if cmd in ('py2exe',): dist_dir = os.path.join('dist',cfg['py2exe.target']) data_dir = dist_dir src = '' dest = cfg['py2exe.binary']+'.py' shutil.copy(src,dest) setup( options={'py2exe':{ 'dist_dir':dist_dir, 'dll_excludes':['_dotblas.pyd','_numpy.pyd'] }}, # windows=[{ console=[{ 'script':dest, # 'icon_resources':[(1,cfg['py2exe.icon'])], }], ) # build the py2app target
if cmd == 'py2app': dist_dir = os.path.join('dist',cfg['py2app.target']+'.app') data_dir = os.path.join(dist_dir,'Contents','Resources') from setuptools import setup src = ''
dest = cfg['py2app.target']+'.py' shutil.copy(src,dest) APP = [dest]
DATA_FILES = [] OPTIONS = {'argv_emulation': True, 'iconfile':cfg['py2app.icon']} setup(
app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, setup_requires=['py2app'], ) # make the cx_freeze target
if cmd == 'cx_freeze': dist_dir = os.path.join('dist',cfg['cx_freeze.target']) data_dir = dist_dir os.system('%s --install-dir %s --target-name %s trek10.py'%(cfg['cx_freeze.cmd'],cfg['cx_freeze.binary'],dist_dir)) # recursively make a bunch of folders
def make_dirs(dname_): parts = list(os.path.split(dname_)) dname = None while len(parts): if dname == None: dname = parts.pop(0) else: dname = os.path.join(dname,parts.pop(0)) if not os.path.isdir(dname): os.mkdir(dname) # copy data into the binaries
if cmd in ('py2exe','cx_freeze','py2app'): dest = data_dir for fname in data: dname = os.path.join(dest,os.path.dirname(fname)) make_dirs(dname) if not os.path.isdir(fname): shutil.copy(fname,dname) |