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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
#!/usr/bin/env python
# Phatch - Photo Batch Processor
# Copyright (C) 2007-2009 www.stani.be
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/
# Linux packagers: please patch lib/linux/path.py, not here!
import sys
NO_WINDOWS = '''
Sorry, the use of 'setup.py install' is not supported yet for Windows.
(You can however use setup.py with py2exe.)
If you want to use Phatch, just run 'python app.py' from the source folder.
Please read the instructions at http://photobatch.wikidot.com/install#toc8
'''
import glob
import os
import subprocess
from distutils.core import setup
sys.path.insert(0, os.path.abspath('phatch'))
from core import info
from lib.context import get_context
CONTEXT = get_context('phatch', base_source=None, sys_prefix='',
user=False)
if CONTEXT['context'] == ('windows', 'package'):
# Do not allow setup.py install as we don't know where to install
# the data, doc and locale path.
sys.exit(NO_WINDOWS)
elif CONTEXT['context'] == ('windows', 'frozen'):
import py2exe
#centralised info generates README and AUTHORS
#Temporarily execute the following statement if these files needs update.
#info.write_readme_credits()
write = sys.stdout.write
error = sys.stderr.write
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Environment :: X11 Applications :: Gnome',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: Dutch',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: OS Independent',
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Artistic Software',
'Topic :: Multimedia :: Graphics',
'Topic :: Multimedia :: Graphics :: Graphics Conversion',
]
def files(*args):
return glob.glob(os.path.join(*args))
def doc(path=''):
return os.path.join(CONTEXT['app_doc_path'], path)
def data(path='', *paths):
return os.path.join(CONTEXT['app_data_path'], path, *paths)
packages = [
'phatch',
'phatch.actions',
'phatch.console',
'phatch.core',
'phatch.lib', 'phatch.lib.pyWx',
'phatch.other', 'phatch.other.pil_1_1_6', 'phatch.other.pyWx',
'phatch.pyWx', 'phatch.pyWx.wxGlade',
'phatch.templates',
]
#Create an array with all the locale filenames
i18n_files = []
for filepath in files('locale', '*', 'LC_MESSAGES', 'phatch.mo'):
targetpath = os.path.dirname(os.path.join(
CONTEXT['app_locale_path'],
filepath,
))
i18n_files.append((targetpath, [filepath]))
#doc
doc_files = [
(doc(),
files('doc', 'build', 'html', '*.html')),
(doc('_static'),
files('doc', 'build', 'html', '_static', '*')),
(doc('_sources'),
files('doc', 'build', 'html', 'sources', '*.txt')),
]
#data
data_files = [
(data(),
[os.path.join('data', 'geek.txt')],
), # eg geek.txt
(data('actionlists'),
files('data', 'actionlists', '*.phatch'),
),
(data('blender'),
files('data', 'blender', '*.blend') + \
files('data', 'blender', '*.py'),
),
(data('fonts'),
files('data', 'fonts', '*.ttf'),
),
(data('gui', 'preview'),
[os.path.join('data', 'gui', 'preview', 'user.png')],
),
(data('gui', 'preview', 'actionlists'),
files('data', 'gui', 'preview', 'actionlists', '*.png'),
),
(data('gui', 'preview', 'blender', 'object'),
files('data', 'gui', 'preview', 'blender', 'object', '*.jpg'),
),
(data('gui', 'preview', 'perspective'),
files('data', 'gui', 'preview', 'perspective', '*.png'),
),
# use 48px for notifications, ...
# TODO Nadia: check if this doesn't look pixelated on Mac Dock
(data('images', 'icons'),
files('setup', 'images', 'icons', '48x48', '*.png'),
),
(data('images', 'highlights'),
files('data', 'images', 'highlights', '*.png'),
),
(data('images', 'masks'),
files('data', 'images', 'masks', '*.png') + \
files('data', 'images', 'masks', '*.jpg')
),
(data('images', 'watermarks'),
files('data', 'images', 'watermarks', '*.png'),
),
]
# rotation previews of blender objects
blender_objects = ('book', 'box', 'can', 'cd', 'lcd', 'sphere')
for ob in blender_objects:
data_files.append((
data('gui', 'preview', 'blender', 'rotation', ob),
files('data', 'gui', 'preview', 'blender', 'rotation', ob,
'*.jpg')))
# os specific files
extra_options = {}
if CONTEXT['windows']:
packages += ['phatch.lib.windows', 'phatch.pyWx.windows']
os_files = [
# phatch specific windows icon
(data('images', 'icons'),
['setup\\images\\icons\\64x64\\phatch.ico'],
),
]
actions = [
'actions.%s' % os.path.splitext(name)[0]
for name in os.listdir('phatch\\actions') if name.endswith('.py')
]
extra_options = {
'windows': [
{
'script': 'phatch/app.py',
'dest_base': 'phatch',
'icon_resources': [
(1, 'setup\\images\\icons\\64x64\\phatch.ico')
],
}
],
'options': {
'py2exe': {
'skip_archive': True,
'includes': ['pyWx.images'] + actions,
},
}
}
elif CONTEXT['apple']:
os_files = [
#man page
('/usr/share/man/man1',
['setup/linux/phatch.1']),
]
else:
#linux
packages += ['phatch.lib.linux', 'phatch.pyWx.linux']
os_files = [
#man page
('share/man/man1',
['setup/linux/phatch.1']),
# desktop shortcut
('share/applications',
files('setup', 'linux', '*.desktop')),
# mime type
('share/mime/packages',
['setup/linux/phatch.xml']),
]
# icons
icon_sizes = [
'%dx%d' % (x, x)
for x in (16, 24, 32, 48, 64, 96, 128, 192, 256)
]
icons = \
[
('share/icons/hicolor/%s/apps' % x,
files('setup', 'images', 'icons', x, '*.png'))
for x in icon_sizes
] + \
[
('share/icons/hicolor/scalable/apps',
files('setup', 'images', 'icons', 'scalable', '*.svg')),
('share/pixmaps',
files('setup', 'images', 'icons', '256x256', '*.png')),
]
os_files.extend(icons)
# setup options
setup_options = {
'packages': packages,
'scripts': ['bin/phatch'],
'data_files': i18n_files + doc_files + data_files + os_files,
'classifiers': classifiers,
}
setup_options.update(info.SETUP)
setup_options.update(extra_options)
if __name__ == '__main__':
#run the setup
dist = setup(**setup_options)
# disabled: distro maintainers do the right thing
# non distro users, who don't use packages at all,
# might need to enable it
if 0 and CONTEXT['linux']:
# Update the mime types
ROOT = os.geteuid() == 0
if ROOT and dist != None:
#update the mimetypes database -> associate.phatch
try:
subprocess.call(["update-mime-database",
os.path.join(sys.prefix, "share/mime/")])
write('Updating the mime types database.\n')
except:
error('Failed to update the mime types database.\n')
#update the .desktop file database -> application menu
try:
subprocess.call(["update-desktop-database"])
write('Updating the .desktop file database.\n')
except:
error('Failed to update the .desktop file database.\n')
write("\nInstallation finished! "
"You can now run Phatch by typing 'phatch' \n"
"or through your applications menu.\n")
|