forked from aehlke/manabi-dict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
170 lines (129 loc) · 5.06 KB
/
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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
from setuptools import setup, Command
import os
from src import manabidict
#from src.manabidict.manabidict import VERSION
import sys
IS_WINDOWS = sys.platform in ('win32', )
if IS_WINDOWS:
import py2exe
SETUP_REQUIRES = ['py2exe']
else:
import py2app
SETUP_REQUIRES = ['py2app']
#install_requires=[
#'lxml>=2.2.4',
#'ebmodule>=2.2',
#]
#from distribute_setup import use_setuptools
#use_setuptools()
class bdist_dmg(Command):
description = "create a Mac disk image (.dmg) binary distribution"
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
#self.run_command('bdist')
os.system('/bin/rm -rf dist')
os.system('/bin/rm -rf build')
self.run_command('py2app')
os.system("mkdir -p dist/Manabi\ Dictionary.app/Contents/Resources/include/python2.6")
os.system("cp /Library/Frameworks/Python.framework/Versions/2.6/include/\
python2.6/pyconfig.h dist/Manabi\ Dictionary.app/Contents/Resources/include/python2.6/pyconfig.h")
os.system('cp qt.conf dist/Manabi\ Dictionary.app/Contents/Resources')
os.system('chmod 755 dist/Manabi\ Dictionary.app/Contents/Resources/mecab/bin/mecab')
os.system('cp -r resources/Python.framework dist/Manabi\ Dictionary.app/Contents/Frameworks/')
os.system('cp /usr/lib/libmecab.1.dylib dist/Manabi\ Dictionary.app/Contents/Frameworks/')
# strip out x86_64 resources
#os.system('ditto --rsrc --arch i386 dist/Manabi\ Dictionary.app dist/Manabi\ Dictionaryi386.app')
#os.system('cp dist/Manabi\ Dictionary.app/Contents/MacOS/Manabi\ Dictionary dist/Manabi\ Dictionaryi386.app/Contents/MacOS/')
#os.system('rm -rf dist/Manabi\ Dictionary.app')
#os.system('mv dist/Manabi\ Dictionaryi386.app dist/Manabi\ Dictionary.app')
# if we strip MacOS/Manabi\ Dictionary, for some reason it will always crash.
#os.system(u'lipo -thin i386 {0}{1} -o {0}{1}'.format('dist/Manabi\ Dictionary.app/Contents/', f))
#make the dmg with the shell script
result = os.system('make-dmg.sh')
if result is not 0:
raise Exception('dmg creation failed %d' % result)
class bdist_exe(Command):
description = "create a Mac disk image (.dmg) binary distribution"
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
os.system('rm -rf dist')
os.system('rm -rf build')
self.run_command('py2exe')
#os.system('cp qt.conf dist/Manabi\ Dictionary.app/Contents/Resources')
#os.system pyc
# py2app stuff
PLIST = {
'CFBundleIdentifier': 'org.manabi.dictionary',
'CFBundleName': 'Manabi Dictionary',
'CFBundleLocalizations': ['en'],
'PyRuntimeLocations': ['@executable_path/../Frameworks/Python.framework/Versions/2.6/Python',]
##'/System/Library/Frameworks/Python.framework/Versions/2.6/Python'],
}
def get_files(file_spec):
import glob
path = os.path.normpath(file_spec)
return glob.glob(path) #filter(lambda x: not x.endswith('CVS'), glob.glob(path))
if IS_WINDOWS:
DATA_FILES = [
('resources/PlugIns/imageformats', get_files('resources/PlugIns/imageformats/*')),
('resources/mecab', get_files('resources/mecab/*')),
]
else:
DATA_FILES = [
'./resources/PlugIns',
'./resources/mecab',
]
PY2APP_OPTIONS = {
'semi_standalone': False,
'iconfile': 'resources/book.icns',
#'argv_emulation': True,
'includes': ['sip', 'PyQt4', 'gzip', 'PyQt4.QtCore', 'PyQt4.QtGui','PyQt4.QtWebKit', 'zlib'],
'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtOpenGL', 'PyQt4.QtScript',
'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtXml', 'phonon',
'QtOpenGL', 'QtXmlPatterns', 'wx', 'tcl', 'Tkinter',
'numpy', 'scipy', 'pygame', 'matplotlib', 'PIL'],
'dylib_excludes': ['libncurses.5.dylib', '_wxagg.so', '_tkagg.so', '_gtkagg.so', 'wx.so'],
'packages': ['lxml'],
'optimize': 0,
'plist': PLIST,
}
# py2exe
PY2EXE_OPTIONS = {
'compressed': False, #True
'optimize': 2,
'bundle_files': 1,
'includes': ['PyQt4', 'sip', 'gzip', 'eb'],#, 'ui'],
'excludes': ['pywin', 'Tkinter', 'Tkconstants', 'tcl', 'PyQt4.phonon', 'PyQt4.QtOpenGL', 'wx'],
'packages': ['lxml'],
}
WINDOWS = [{
'script': 'src/manabidict/manabidict.py',
#'icon_resources': [(1, '')]
}]
setup(
name='Manabi Dictionary',
version='0.000002',
description='A viewer for EPWING-formatted Japanese dictionaries.',
author='Alex Ehlke',
url='http://manabi.org',
license='GPLv3',
app=['src/manabidict/manabidict.py'],
zip_safe=False,
#include_package_data=True,
data_files=DATA_FILES,
install_requires = ['PyQt4'],
options={
'py2app': PY2APP_OPTIONS,
'py2exe': PY2EXE_OPTIONS,
},
windows=WINDOWS,
setup_requires=SETUP_REQUIRES,
#cmdclass = {'bdist_dmg': bdist_dmg, 'bdist': bdist},
#cmdclass = { 'bdist': bdist},
cmdclass = { 'bdist_dmg': bdist_dmg},
)
#os.system(