changeset 548:366e58e8d057

Much simpler py2exe file.
author Simon Cross <hodgestar@gmail.com>
date Sun, 10 Apr 2011 01:09:37 +0200
parents 0ddfbb5b1ae7
children b7f912705adb
files setup.py
diffstat 1 files changed, 100 insertions(+), 251 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Sun Apr 10 01:09:27 2011 +0200
+++ b/setup.py	Sun Apr 10 01:09:37 2011 +0200
@@ -1,266 +1,115 @@
-# 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...
-
-import glob
-import os
-import shutil
-import sys
-
-from setuptools import setup, find_packages, Extension
-try:
-    import py2exe
-except:
-    pass
-
-
-
-APP_NAME = 'skaapsteker'
-DESCRIPTION = open('README.txt').read()
-CHANGES = open('CHANGES.txt').read()
-TODO = open('TODO.txt').read()
-
-
+# setup.py
+# -*- coding: utf8 -*-
+# vim:fileencoding=utf8 ai ts=4 sts=4 et sw=4
 
-METADATA = {
-    'name':APP_NAME,
-    'version':          '0.0.1',
-    'license':          'short_licence',
-    'description':      '',
-    'author':           'Adrianna Pinska, Anna Malczyk, Jeremy Thurgood, Neil Muller, Oliver Hambsch, Simon Cross, Stefano Rivera',
-    #'author_email':     '',
-    'url':              'http://pyweek.org/e/skaapsteker',
-    'classifiers':      [
-            'Development Status :: 4 - Beta',
-            'Intended Audience :: End Users/Desktop',
-            'Intended Audience :: Information Technology',
-            'License :: OSI Approved :: BSD License',
-            'Operating System :: OS Independent',
-            'Programming Language :: Python :: 2',
-            'Programming Language :: Python :: 2.6',
-            'Programming Language :: Python :: 2.7',
-            'Topic :: Software Development :: Libraries :: pygame',
-            'Topic :: Games/Entertainment :: Real Time Strategy',
-    ],
-
+"""Setuptools setup.py file for Skaapsteker."""
 
-    'py2exe.target':'',
-    #'py2exe.icon':'icon.ico', #64x64
-    'py2exe.binary':APP_NAME, #leave off the .exe, it will be added
-    
-    'py2app.target':APP_NAME,
-    'py2app.icon':'icon.icns', #128x128
-    
-    #'cx_freeze.cmd':'~/src/cx_Freeze-3.0.3/FreezePython',
-    'cx_freeze.cmd':'cxfreeze',
-    'cx_freeze.target':'%s_linux' % APP_NAME,
-    'cx_freeze.binary':APP_NAME,
-    }
-    
-files_to_remove = ['tk84.dll',
-                    '_ssl.pyd',
-                    'tcl84.dll',
-                    os.path.join('numpy','core', '_dotblas.pyd'),
-                    os.path.join('numpy', 'linalg', 'lapack_lite.pyd'),
-]
-
-
-directories_to_remove = [os.path.join('numpy', 'distutils'),
-                         'distutils',
-                         'tcl',
-]
-
-
-cmdclass = {}
-PACKAGEDATA = {
-    'cmdclass':    cmdclass,
-    'packages': find_packages(),
-    'scripts': ['scripts/skaapsteker'],
-}
-
-PACKAGEDATA.update(METADATA)
-
+from setuptools import setup, find_packages
 
 try:
-    cmd = sys.argv[1]
-except IndexError:
-    print 'Usage: setup.py install|py2exe|py2app|cx_freeze'
-    raise SystemExit
+    import py2exe
+except ImportError:
+    pass
 
-# 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)
+VERSION_STR = "0.1"
 
-        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)
+setup   (   # Metadata
+            name = "Nine Tales of the Kitsune",
+            version = VERSION_STR,
+            description = "Platformer for PyWeek 12",
 
-# define what is our data
-_DATA_DIR = 'data'
-data = []
-add_files(data,os.walk(_DATA_DIR))
-
-
-
-
-#data_dirs = [os.path.join(f2.replace(_DATA_DIR, 'data'), '*') for f2 in data]
-data_dirs = [os.path.join(f2.replace(_DATA_DIR, 'data')) for f2 in data]
-PACKAGEDATA['package_data'] = {'skaapsteker': data_dirs}
+            author = ("Adrianna Pinska, Anna Malczyk, Jeremy Thurgood, "
+                      "Neil Muller, Oliver Hambsch, Simon Cross, Stefano Rivera"),
+            author_email = "",
 
-
-
-
+            maintainer = "Skaapsteker Team",
+            maintainer_email = "ctpug@googlegroups.com",
 
-data.extend(glob.glob('*.txt'))
-#data.append('MANIFEST.in')
-# define what is our source
-src = []
-add_files(src,os.walk('skaapsteker'))
-src.extend(glob.glob('*.py'))
+            url = "http://ctpug.org.za/",
+            download_url = "https://ctpug.org.za/hg/skaapsteker/",
 
+            license = "MIT",
 
-
-
-# build the sdist target
-if cmd not in "py2exe py2app cx_freeze".split():
-    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(**PACKAGEDATA)
+            classifiers = [
+                  'Development Status :: 4 - Beta',
+                  'Environment :: MacOS X',
+                  'Environment :: Win32 (MS Windows)',
+                  'Environment :: X11 Applications',
+                  'Intended Audience :: End Users/Desktop',
+                  'License :: OSI Approved :: MIT License',
+                  'Natural Language :: English',
+                  'Operating System :: Microsoft :: Windows',
+                  'Operating System :: POSIX',
+                  'Operating System :: MacOS :: MacOS X',
+                  'Programming Language :: Python :: 2.5',
+                  'Programming Language :: Python :: 2.6',
+                  'Topic :: Games/Entertainment :: Role-Playing',
+                  'Topic :: Games/Entertainment :: Arcade',
+             ],
 
-# build the py2exe target
-if cmd in ('py2exe',):
-    dist_dir = os.path.join('dist',METADATA['py2exe.target'])
-    data_dir = dist_dir
-    
-    src = 'run_game.py'
-    dest = METADATA['py2exe.binary']+'.py'
-    shutil.copy(src,dest)
-    
-    setup(
-        options={'py2exe':{
-            'dist_dir':dist_dir,
-            'dll_excludes':['_dotblas.pyd','_numpy.pyd', 'numpy.linalg.lapack_lite.pyd', 'numpy.core._dotblas.pyd'] + files_to_remove,
-            'excludes':['matplotlib', 'tcl', 'OpenGL'],
-            'ignores':['matplotlib', 'tcl', 'OpenGL'],
-            'bundle_files':1,
-            }},
-#        windows=[{
-       console=[{
-            'script':dest,
-            #'icon_resources':[(1,METADATA['py2exe.icon'])],
-            }],
-        )
+            platforms = [
+                  'Linux',
+                  'Mac OS X',
+                  'Windows',
+            ],
 
-# build the py2app target
-if cmd == 'py2app':
-    dist_dir = os.path.join('dist',METADATA['py2app.target']+'.app')
-    data_dir = os.path.join(dist_dir,'Contents','Resources')
-
-    src = 'run_game.py'
-    dest = METADATA['py2app.target']+'.py'
-    shutil.copy(src,dest)
+            # Dependencies
+            install_requires = [],
 
-    APP = [dest]
-    DATA_FILES = []
-    OPTIONS = {'argv_emulation': True, 
-               #'iconfile':METADATA['py2app.icon']
-              }
-
-    setup(
-        app=APP,
-        data_files=DATA_FILES,
-        options={'py2app': OPTIONS},
-        setup_requires=['py2app'],
-    )
-
-# make the cx_freeze target
-if cmd == 'cx_freeze':
-    app_dist_dir = METADATA['cx_freeze.target'] + "_" + METADATA['version']
-    dist_dir = os.path.join('dist', app_dist_dir)
-    data_dir = dist_dir
-
-    modules_exclude = "tcl,tk"
-    cmd_args = (METADATA['cx_freeze.cmd'], dist_dir, METADATA['cx_freeze.binary'], modules_exclude)
-    sys_cmd = '%s --install-dir=%s --target-name=%s --exclude-modules=%s run_game.py' % cmd_args
-    print sys_cmd
-    os.system(sys_cmd)
-
-    import shutil
-    if os.path.exists(os.path.join(data_dir, "tcl")): 
-        shutil.rmtree( os.path.join(data_dir, "tcl") )
-    if os.path.exists(os.path.join(data_dir, "tk")): 
-        shutil.rmtree( os.path.join(data_dir, "tk") )
-
-
-
-# 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)
+            # Files
+            packages = find_packages(),
+            scripts = [
+                  'scripts/skaapsteker'
+            ],
 
-# 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):
-            #print (fname,dname)
-            shutil.copy(fname,dname)
-
-# make a tgz files.
-if cmd == 'cx_freeze':
-    sys_cmd = "cd dist; tar -vczf %s.tgz %s/" % (app_dist_dir,app_dist_dir)  
-    os.system(sys_cmd)
-
-
-# remove files from the zip.
-if 0 and cmd in ('py2exe'):
-    import shutil
-
-    #shutil.rmtree( os.path.join('dist') )
-    #shutil.rmtree( os.path.join('build') )
-
-
-    os.system("unzip dist/library.zip -d dist\library")
-
-    for fn in files_to_remove:
-        os.remove( os.path.join('dist', 'library', fn) )
-
-
-    for d in directories_to_remove:
-        if os.path.exists( os.path.join('dist', 'library', d) ):
-            shutil.rmtree( os.path.join('dist', 'library', d) )
-
-    os.remove( os.path.join('dist', 'library.zip') )
-
-
-    os.chdir("dist")
-    os.chdir("library")
-
-    os.system("zip -r -9 ..\library.zip .")
-
-    os.chdir("..")
-    os.chdir("..")
+            # py2exe
+            console = ['scripts/testconsole.py'],
+            windows = [{
+                'script': 'scripts/skaapsteker',
+                'icon_resources': [(0, "data/icons/program/icon.ico")],
+            }],
+            app = ['scripts/skaapsteker'],
+            options = {
+            'py2exe': {
+                'skip_archive': 1,
+                'dist_dir': 'dist/nine-tales-%s' % VERSION_STR,
+                'packages': [
+                    'logging', 'encodings', 'skaapsteker',
+                ],
+                'includes': [
+                    # pygame
+                    'pygame',
+                ],
+                'excludes': [
+                    'numpy',
+                ],
+                'ignores': [
+                    # all database modules
+                    'pgdb', 'Sybase', 'adodbapi',
+                    'kinterbasdb', 'psycopg', 'psycopg2', 'pymssql',
+                    'sapdb', 'pysqlite2', 'sqlite', 'sqlite3',
+                    'MySQLdb', 'MySQLdb.connections',
+                    'MySQLdb.constants.CR', 'MySQLdb.constants.ER',
+                    # old datetime equivalents
+                    'DateTime', 'DateTime.ISO',
+                    'mx', 'mx.DateTime', 'mx.DateTime.ISO',
+                    # email modules
+                    'email.Generator', 'email.Iterators', 'email.Utils',
+                ],
+            },
+            'py2app': {
+                'argv_emulation': 1,
+                'iconfile': 'data/icons/program/icon.icns',
+#                 'dist_dir': 'dist/nine-tales-%s' % VERSION_STR,
+#                 'bdist_base': 'build/bdist',
+                'packages': [
+                    'logging', 'encodings', 'pygame', 'skaapsteker', 'data',
+                ],
+                'excludes': ['numpy'],
+            }},
+            data_files = [
+                # 'COPYRIGHT',
+                'LICENSE.txt',
+                'README.txt',
+            ],
+        )