My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#! /usr/bin/env python
#
# $Id$

import sys, os, zipfile, shutil

from distutils.core import setup
from distutils.cmd import Command

from bruce import __version__

# Application script file contents
LINUX_SCRIPT = '''#! /usr/bin/env python

# force module loading from my zip file first
import sys, os
zip_path = os.path.join(os.path.dirname(sys.argv[0]), 'bruce-library.zip')
sys.path.insert(0, zip_path

from bruce import %(module_name)s
%(module_name)s.main()
'''
LINUX_DESKTOP = '''[Desktop Entry]
Version=1.0
Type=Application
Name=Bruce, the Presentation Tool
Comment=The bestest Presentation Tool evah!
Exec=bruce %f
Icon=video XXX need my own icon...
MimeType=text/x-rst
'''
OSX_SCRIPT = LINUX_SCRIPT.replace('python', 'pythonw')
WINDOWS_SCRIPT = '''import sys\r
# force module loading from my zip file first\r
sys.path.insert(0, 'bruce-library.zip')\r
\r
from bruce import %(module_name)s\r
%(module_name)s.main()\r
'''

SCRIPTS = [
('bruce', 'run'),
('bruce2html', 'html_ouput'),
]

class BuildApps(Command):
'''Special distutils command used to build the application zip files
for the three operating systems. Also builds the examples zip file.
'''
description = 'Build application bundles'
user_options = []

def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# build the library zip file
if not os.path.exists('build'):
os.mkdir('build')
if not os.path.exists('dist'):
os.mkdir('dist')
zipname = 'build/bruce-library.zip'
if os.path.exists(zipname):
os.remove(zipname)
z = zipfile.PyZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
z.write(os.path.join('docutils-extras', 'roman.py'), 'roman.py')

def writepy(path):
dirlist = os.listdir(path)
for filename in dirlist:
filename = os.path.join(path, filename)
if os.path.isfile(os.path.join(filename, "__init__.py")):
# This is a package directory, add it
writepy(filename)
elif filename.endswith('.py'):
z.write(filename)

for name in 'bruce pyglet cocos docutils pygments'.split():
writepy(name)
z.close()

self.distribution.metadata.write_pkg_info('build')

# zip contents shared by all
dirname = self.distribution.get_fullname()
def basics(zipname):
self.distribution.dist_files.append(('sdist', '', zipname))
z = zipfile.ZipFile(zipname, 'w')
for file in 'bruce-library.zip PKG-INFO'.split():
z.write('build/%s'%file, '%s/%s'%(dirname, file))

for file in 'README.txt HOWTO.txt CHANGES.txt'.split():
z.write(file, '%s/%s'%(dirname, file))
return z

# build Linux
z = basics('dist/bruce-%s-linux.zip'%__version__)
for script, module_name in SCRIPTS:
open('build/%s.sh'%script, 'w').write(LINUX_SCRIPT%locals())
os.chmod('build/%s.sh'%script, 0755)
z.write('build/%s.sh'%script, '%s/%s.sh'%(dirname, script))
z.close()

# build OS X
z = basics('dist/bruce-%s-osx.zip'%__version__)
for script, module_name in SCRIPTS:
open('build/%s.sh'%script, 'w').write(OSX_SCRIPT%locals())
os.chmod('build/%s.sh'%script, 0755)
z.write('build/%s.sh'%script, '%s/%s.sh'%(dirname, script))
z.close()

# build WINDOWS
z = basics('dist/bruce-%s-windows.zip'%__version__)
for script, module_name in SCRIPTS:
open('build/%s.pyw'%script, 'w').write(WINDOWS_SCRIPT%locals())
z.write('build/%s.pyw'%script, '%s/%s.pyw'%(dirname, script))
z.close()

# build examples
zipname = 'dist/bruce-%s-examples.zip'%__version__
self.distribution.dist_files.append(('sdist', '', zipname))
z = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
dirname = 'bruce-%s-examples'%__version__
for file in os.listdir('examples'):
subfile = os.path.join('examples', file)
if os.path.isfile(subfile):
z.write(subfile, '%s/%s'%(dirname, file))
z.write('build/PKG-INFO', '%s/PKG-INFO'%dirname)
z.close()

# perform the setup action
setup(
name = "bruce",
version = __version__,
description = "Bruce, the Presentation Tool, puts reStructuredText in your projector",
long_description = ''.join(open('README.txt').readlines()[4:-28]),
author = "Richard Jones",
author_email = "richard@mechanicalcat.net",
url = "http://r1chardj0n3s.googlepages.com/bruce",
download_url = "http://code.google.com/p/bruce-tpt/downloads/list",
packages = ["bruce"],
scripts = ['scripts/bruce'],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Topic :: Multimedia :: Graphics :: Presentation',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
],
cmdclass = dict(
build_apps = BuildApps,
),
)

# vim: set filetype=python ts=4 sw=4 et si
Show details Hide details

Change log

r233 by r1chardj0n3s on Feb 25, 2009   Diff
some command-line improvements
Go to: 
Project members, sign in to write a code review

Older revisions

r232 by r1chardj0n3s on Feb 09, 2009   Diff
Add HTML output using standard
docutils where possible and providing
custom directive handlers for the
Bruce stuff.
Add simple interface with even simpler
...
r224 by r1chardj0n3s on Jan 22, 2009   Diff
fix windows .pyw launcher script
r217 by r1chardj0n3s on Jan 14, 2009   Diff
fix
All revisions of this file

File info

Size: 5343 bytes, 157 lines
Hosted by Google Code