Skip to content

Commit

Permalink
Windows build by Ignas
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Jan 29, 2011
1 parent e60e64b commit 5f455d9
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
Binary file removed assets/dodo.png
Binary file not shown.
1 change: 1 addition & 0 deletions py2exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c:\Python26\python.exe setup.py py2exe
122 changes: 122 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
APP_NAME = 'Dodopult'


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
}

# usage: python setup.py command
#
# sdist - build a source dist
# py2exe - build an exe
#
# 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'
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('assets'))
print data
data.extend(glob.glob('*.txt'))
data.extend(glob.glob('*.png'))
# 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=cfg['url'],
)

# build the py2exe target
if cmd in ('py2exe',):
dist_dir = os.path.join('dist',cfg['py2exe.target'])
data_dir = dist_dir

src = 'dodo.py'
dest = cfg['py2exe.binary']+'.py'
shutil.copy(src,dest)

setup(
options={'py2exe':{
'dist_dir':dist_dir,
'dll_excludes':['_dotblas.pyd','_numpy.pyd']
}},
windows=[{
'script':dest,
#'icon_resources':[(1,cfg['py2exe.icon'])],
}],
)

# 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',):
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)

0 comments on commit 5f455d9

Please sign in to comment.