-
Notifications
You must be signed in to change notification settings - Fork 3
/
mac-setup.py
126 lines (110 loc) · 3.94 KB
/
mac-setup.py
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
#!/usr/bin/python
# setup.py
import glob
import os
import time
import subprocess
from distutils.command.install import install
from distutils.core import setup
from exe.engine.path import Path
import py2app
# update the svn revision number
REVISION_FILE = 'exe/engine/version_svn.py'
try:
os.unlink(REVISION_FILE)
except OSError:
pass
revision = None
try:
psvn = subprocess.Popen('svnversion', stdout=subprocess.PIPE)
psvn.wait()
revision = psvn.stdout.read().strip()
except OSError:
print "*** Warning: 'svnversion' tool not available to update revision number"
finally:
if revision is None or revision == 'exported':
revision = time.strftime('%Y%m%d%H%M')
open(REVISION_FILE, 'wt').write('revision = "%s"\n' % revision)
from exe.engine import version
# Make main.py if it doesn't exist
if not Path('exe/main.py').exists():
lines = open('exe/exe').readlines()
for i, line in enumerate(lines):
if line.startswith('import'):
lines.insert(i, 'import decimal\n')
break
output = open('exe/main.py', 'w')
output.writelines(lines)
output.close()
files = { '../Resources/exe': ["README",
"COPYING",
"NEWS",
"ChangeLog",
"exe/webui/mr_x.gif"],
'../Resources' : ["exe_elp.icns"],
}
def dataFiles(baseSourceDir, baseDestDir, sourceDirs, excludes=[]):
"""Recursively get all the files in these directories"""
baseSourceDir = Path(baseSourceDir)
baseDestDir = Path(baseDestDir)
sourceDirs = map(Path, sourceDirs)
for sourceDir in sourceDirs:
sourceDir = baseSourceDir/sourceDir
for subDir in list(sourceDir.walkdirs()) + [sourceDir]:
if '.svn' in subDir.splitall():
continue
newExtDir = baseSourceDir.relpathto(subDir)
fileList = files.setdefault(baseDestDir/newExtDir, [])
for file in subDir.files():
if file.name not in excludes:
fileList.append(file)
# Add all the webui dirs
dataFiles('exe/webui', '../Resources/exe',
['style', 'css', 'images', 'docs', 'linux-profile',
'scripts', 'schemas', 'templates',
'firefox'],
excludes=['mimetex.cgi', 'mimetex.64.cgi', 'mimetex.exe'])
# Add in the
dataFiles('exe', '../Resources/exe', ['locale'])
dataFiles('exe/xului', '../Resources/exe', ['scripts', 'templates'])
import sys
print sys.path
plist = dict(
CFBundleDocumentTypes = [
dict(
CFBundleTypeExtensions=['elp'],
CFBundleTypeIconFile='exe_elp.icns',
CFBundleTypeMIMETypes=['text/xml'],
CFBundleTypeName='Binary',
CFBundleTypeRole='Editor',
LSTypeIsPackage=False,
NSDocumentClass='MyDocument',
NSPersistentStoreTypeKey='Binary',
),
],
)
py2appParams = {
'includes': 'PngImagePlugin,JpegImagePlugin,GifImagePlugin,IcoImagePlugin,BmpImagePlugin',
'packages': 'encodings,nevow',
'argv_emulation': True,
'plist' : plist,
'iconfile': 'exe.icns'}
setup(name = version.project,
version = version.release,
description = "eLearning XHTML editor",
long_description = """\
The eXe project is an authoring environment to enable teachers to publish
web content without the need to become proficient in HTML or XML markup.
Content generated using eXe can be used by any Learning Management System.
""",
url = "http://exelearning.org",
author = "eXe Project",
author_email = "[email protected]",
license = "GPL",
packages = ["exe", "exe.webui", "exe.xului",
"exe.engine", "exe.export"],
data_files = files.items(),
app = ["exe/main.py"],
options = {'py2app': py2appParams},
setup_requires = ["py2app"],
)