-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
735 lines (654 loc) · 34.4 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
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Copyright 2008, 2009, 2010 Hugo Párraga Martín
This file is part of PyCamimg.
PyCamimg 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.
PyCamimg 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 PyCamimg. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
from ez_setup import use_setuptools
use_setuptools()
from distutils.core import setup, Distribution, Command
# from distutils.core import setup, find_packages
import glob
import os
import os.path as path
import sys
import pkg_resources
import ConfigParser
try:
import py2exe
buildExe = py2exe.build_exe.py2exe
Distribution = py2exe.Distribution
except:
py2exe = None
buildExe = Command
try:
import py2app
except ImportError:
py2app = None
iconsTheme = "gnome"
gtkTheme = "Industrial"
try:
# if this doesn't work, try import modulefinder
import py2exe.mf as modulefinder
import win32com
for p in win32com.__path__[1:]:
modulefinder.AddPackagePath("win32com", p)
for extra in ["win32com.shell"]: # ,"win32com.mapi"
__import__(extra)
m = sys.modules[extra]
for p in m.__path__[1:]:
modulefinder.AddPackagePath(extra, p)
except ImportError:
# no build path setup, no worries.
print("Error")
pass
updateConfigAtEnd = False
exePath, setupFile = path.split(__file__)
versionFile = path.join(exePath, "src", "share", "pycamimg", "config", "version.cfg")
languagesFile = path.join(exePath, "src", "share", "pycamimg", "locale", "availables.cfg")
version = ConfigParser.ConfigParser()
failLoad = False
try:
# Try to read the version file
version.read([versionFile])
except:
failLoad = True
if (failLoad):
raise Exception("Can't not open version file: %s" % versionFile)
languages = ConfigParser.ConfigParser()
listLanguages = []
failLanguages = False
try:
languages.read([languagesFile])
listLanguages = languages.sections()
except:
failLanguages = True
__description__ = version.get("pycamimg", "short_description")
__name__ = version.get("pycamimg", "name_program")
__version__ = version.get("pycamimg", "version")
__author__ = version.get("pycamimg", "authors")
__email__ = version.get("pycamimg", "email")
__license__ = version.get("pycamimg", "alt_license")
__url__ = version.get("pycamimg", "website")
__copyright__ = version.get("pycamimg", "copyright")
__filename__ = version.get("pycamimg", "filename")
__exefilename__ = version.get("pycamimg", "exefilename")
__dependencies__ = ["gtk",
"gtk.glade",
"pygtk",
"gobject",
"PIL",
"PIL.ImageOps",
"jpeg",
"gettext",
"pkg_resources",
"pango",
"gdata",
"elementtree"]
if (sys.platform == "win32"):
__dependencies__.append("ctypes")
__dependencies__.append("win32api")
__dependencies__.append("win32com")
__dependencies__.append("win32con")
__dependencies__.append("win32com.shell")
# __dependencies__.append("win32com.shellcon")
__package_data__ = {
}
__data_files__ = [
(path.join("share", "pycamimg"), [
path.join("src", "share", "pycamimg", "COPYING")
]),
(path.join("share", "pycamimg", "config"), [
path.join("src", "share", "pycamimg", "config", "config.cfg"),
path.join("src", "share", "pycamimg", "config", "version.cfg")
]),
(path.join("share", "pycamimg", "locale"), [
path.join("src", "share", "pycamimg", "locale", "pycamimg.pot"),
path.join("src", "share", "pycamimg", "locale", "files_gettext.list"),
path.join("src", "share", "pycamimg", "locale", "availables.cfg"),
path.join("src", "share", "pycamimg", "locale", "en.po"),
path.join("src", "share", "pycamimg", "locale", "es.po"),
path.join("src", "share", "pycamimg", "locale", "pycamimg.pot")
]),
(path.join("share", "pycamimg", "locale", "en", "LC_MESSAGES"), [
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "FacebookPlugin.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "LocalProjectPlugin.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "pycamimg.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "RenameOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "ResizeOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "RotateOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "GrayScaleOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "SepiaToneOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "en", "LC_MESSAGES", "FlipOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "fbcore.mo")
]),
(path.join("share", "pycamimg", "locale", "es", "LC_MESSAGES"), [
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "FacebookPlugin.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "LocalProjectPlugin.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "pycamimg.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "RenameOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "ResizeOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "RotateOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "GrayScaleOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "SepiaToneOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "FlipOperation.mo"),
path.join("src", "share", "pycamimg", "locale", "es", "LC_MESSAGES", "fbcore.mo")
]),
(path.join("share", "pycamimg", "icons"), [
path.join("src", "share", "pycamimg", "icons", "pycamimg.bmp"),
path.join("src", "share", "pycamimg", "icons", "pycamimg.png"),
path.join("src", "share", "pycamimg", "icons", "pycamimg.ico"),
path.join("src", "share", "pycamimg", "icons", "facebook.png"),
path.join("src", "share", "pycamimg", "icons", "pycamimg.png"),
path.join("src", "share", "pycamimg", "icons", "loading.gif"),
path.join("src", "share", "pycamimg", "icons", "rename.gif"),
path.join("src", "share", "pycamimg", "icons", "resize.png"),
path.join("src", "share", "pycamimg", "icons", "rotate.png"),
path.join("src", "share", "pycamimg", "icons", "rotateLeft.gif"),
path.join("src", "share", "pycamimg", "icons", "rotateRight.gif"),
path.join("src", "share", "pycamimg", "icons", "lock.png"),
path.join("src", "share", "pycamimg", "icons", "grayscale.png"),
path.join("src", "share", "pycamimg", "icons", "sepiatone.png"),
path.join("src", "share", "pycamimg", "icons", "mirror.png"),
path.join("src", "share", "pycamimg", "icons", "flip.png"),
path.join("src", "share", "pycamimg", "icons", "fb-connect.png")
]),
(path.join("share", "pycamimg", "plugins"), [
path.join("src", "share", "pycamimg", "plugins", "__init__.py")
]),
(path.join("share", "pycamimg", "plugins", "localproject"), [
path.join("src", "share", "pycamimg", "plugins", "localproject", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "localproject", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "localproject", "LocalProject.py")
]),
(path.join("share", "pycamimg", "plugins", "localproject", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "localproject", "locale", "LocalProjectPlugin.pot"),
path.join("src", "share", "pycamimg", "plugins", "localproject", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "localproject", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "facebookproject"), [
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "FacebookProj.py"),
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "AlbumSelection.py")
]),
(path.join("share", "pycamimg", "plugins", "facebookproject", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "locale", "FacebookPlugin.pot"),
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "facebookproject", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "fbcore"), [
path.join("src", "share", "pycamimg", "plugins", "fbcore", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "AuthDialog.py"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "SessionFB.py")
]),
(path.join("share", "pycamimg", "plugins", "fbcore", "lib"), [
path.join("src", "share", "pycamimg", "plugins", "fbcore", "lib", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "lib", "facelib.py")
]),
(path.join("share", "pycamimg", "plugins", "fbcore", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "fbcore", "locale", "fbcore.pot"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "fbcore", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "RenameOperation"), [
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "RenameDialog.py"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "RenamePlugin.py")
]),
(path.join("share", "pycamimg", "plugins", "RenameOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "locale", "RenameOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "RenameOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "ResizeOperation"), [
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "ResizeDialog.py"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "ResizePlugin.py")
]),
(path.join("share", "pycamimg", "plugins", "ResizeOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "locale", "ResizeOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "ResizeOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "RotateOperation"), [
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "RotateDialog.py"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "RotatePlugin.py")
]),
(path.join("share", "pycamimg", "plugins", "RotateOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "locale", "RotateOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "RotateOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "GrayScaleOperation"), [
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "GrayScalePlugin.py")
]),
(path.join("share", "pycamimg", "plugins", "GrayScaleOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "locale", "GrayScaleOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "GrayScaleOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "SepiaToneOperation"), [
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "SepiaTonePlugin.py")
]),
(path.join("share", "pycamimg", "plugins", "SepiaToneOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "locale", "SepiaToneOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "SepiaToneOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "FlipOperation"), [
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "Operation.py"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "FlipPlugin.py"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "FlipDialog.py")
]),
(path.join("share", "pycamimg", "plugins", "FlipOperation", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "locale", "FlipOperation.pot"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "FlipOperation", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "picasaproject"), [
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "PicasaProj.py"),
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "AlbumSelection.py")
]),
(path.join("share", "pycamimg", "plugins", "picasaproject", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "locale", "PicasaPlugin.pot"),
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "picasaproject", "locale", "es.po")
]),
(path.join("share", "pycamimg", "plugins", "gdatacore"), [
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "__init__.py"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "camimgplugin.py"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "AuthDialog.py"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "Session.py"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "LoginDialog.py")
]),
(path.join("share", "pycamimg", "plugins", "gdatacore", "locale"), [
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "locale", "gdatacore.pot"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "locale", "en.po"),
path.join("src", "share", "pycamimg", "plugins", "gdatacore", "locale", "es.po")
]),
(path.join("share", "pycamimg", "scripts"), [
path.join("src", "share", "pycamimg", "scripts", "db_scheme.sql"),
]),
(path.join("share", "pycamimg", "xml"), [
path.join("src", "share", "pycamimg", "xml", "MainMenu.xml"),
path.join("src", "share", "pycamimg", "xml", "execute.xml"),
path.join("src", "share", "pycamimg", "xml", "Explorer.xml"),
path.join("src", "share", "pycamimg", "xml", "facebookproject.xml"),
path.join("src", "share", "pycamimg", "xml", "flipoperation.xml"),
path.join("src", "share", "pycamimg", "xml", "grayscaleoperation.xml"),
path.join("src", "share", "pycamimg", "xml", "localproject.xml"),
path.join("src", "share", "pycamimg", "xml", "renameoperation.xml"),
path.join("src", "share", "pycamimg", "xml", "resizeoperation.xml"),
path.join("src", "share", "pycamimg", "xml", "rotateoperation.xml"),
path.join("src", "share", "pycamimg", "xml", "sepiatoneoperation.xml")
]),
]
__script__ = path.join("src", "camimg.py")
__packages__ = ["pycamimg",
"pycamimg.core",
"pycamimg.core.db",
"pycamimg.core.operations",
"pycamimg.core.photoalbum",
"pycamimg.core.plugins",
"pycamimg.ui",
"pycamimg.util",
]
# Some of these depend on some files to be built externally before running
# setup.py, like the .xml and .desktop files
options = {}
def get_innosetup_compile():
try:
import _winreg
compile_key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, "innosetupscriptfile\\shell\\compile\\command")
compilecommand = _winreg.QueryValue(compile_key, "")
compile_key.Close()
except:
compilecommand = "compil32.exe"
return compilecommand
def chop(dist_dir, pathname):
"""returns the path relative to dist_dir"""
assert pathname.startswith(dist_dir)
return pathname[len(dist_dir):]
def create_inno_script(name, _lib_dir, dist_dir, exe_files, other_files, version="1.0"):
if not dist_dir.endswith(os.sep):
dist_dir += os.sep
exe_files = [chop(dist_dir, p) for p in exe_files]
other_files = [chop(dist_dir, p) for p in other_files]
pathname = path.join(dist_dir, name + os.extsep + "iss")
# See http://www.jrsoftware.org/isfaq.php for more InnoSetup config options.
ofi = open(pathname, "w")
print >> ofi, r'''; WARNING: This script has been created by py2exe. Changes to this script
; will be overwritten the next time py2exe is run!
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Setup]
AppName=%(name)s
AppVerName=%(name)s %(version)s
AppPublisher=Hugo Párraga Martín
AppPublisherURL=http://babytuxexperience.blogspot.com
AppSupportURL=http://babytuxexperience.blogspot.com
AppUpdatesURL=http://babytuxexperience.blogspot.com
;AppComments=
AppCopyright=Copyright (C) 2008-2010 Hugo Párraga Martín
DefaultDirName={pf}\%(name)s
DefaultGroupName=%(name)s
LicenseFile=%(license)s
OutputDir=%(output)s
OutputBaseFilename=%(name)s-%(version)s-setup
ChangesAssociations=yes
SetupIconFile=%(icon_path)s
;WizardSmallImageFile=compiler:images\WizModernSmallImage13.bmp
WizardImageFile=%(wizard_image)s
Compression=lzma
SolidCompression=yes
[Files]''' % {
'name': __name__,
'version': __version__,
'icon_path': path.join(path.abspath("src"), "share", "pycamimg", "icons", "pycamimg.ico"),
'wizard_image': path.join(path.abspath("src"), "share", "pycamimg", "icons", "pycamimg.bmp"),
'license': path.join(path.abspath("src"), "share", "pycamimg", "COPYING"),
'output': path.abspath("dist")
}
for fpath in exe_files + other_files:
print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags: ignoreversion' % (fpath, os.path.dirname(fpath))
print >> ofi, r'''
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Icons]
Name: "{group}\%(name)s"; Filename: "{app}\%(exefilename)s.exe";
Name: "{group}\Uninstall %(name)s"; Filename: "{uninstallexe}";
Name: "{commondesktop}\%(name)s"; Filename: "{app}\%(exefilename)s.exe"; Tasks: desktopicon''' % {'name': __name__, 'exefilename': __exefilename__}
# Show a "Launch Virtaal" checkbox on the last installer screen
print >> ofi, r'''
[Run]
Filename: "{app}\%(exefilename)s.exe"; Description: "{cm:LaunchProgram,%(name)s}"; Flags: nowait postinstall skipifsilent''' % {'name': __name__, 'exefilename': __exefilename__}
print >> ofi
ofi.close()
return pathname
def compile_inno_script(script_path):
"""compiles the script using InnoSetup"""
shell_compile_command = get_innosetup_compile()
compile_command = shell_compile_command.replace('"%1"', script_path)
result = os.system(compile_command)
if result:
print("Error compiling iss file")
print("Opening iss file, use InnoSetup GUI to compile manually")
os.startfile(script_path)
class BuildWin32Installer(buildExe):
"""distutils class that first builds the exe file(s), then creates a Windows installer using InnoSetup"""
description = "create an executable installer for MS Windows using InnoSetup and py2exe"
user_options = getattr(buildExe, 'user_options', []) + \
[('install-script=', None,
"basename of installation script to be run after installation or before deinstallation")]
def initialize_options(self):
buildExe.initialize_options(self)
def run(self):
# First, let py2exe do it's work.
buildExe.run(self)
# create the Installer, using the files py2exe has created.
exe_files = self.windows_exe_files + self.console_exe_files
print("*** creating the inno setup script***")
script_path = create_inno_script(__name__, self.lib_dir, self.dist_dir, exe_files, self.lib_files,
version=self.distribution.metadata.version)
print("*** compiling the inno setup script***")
compile_inno_script(script_path)
# Note: By default the final setup.exe will be in an Output subdirectory.
def find_gtk_bin_directory():
GTK_NAME = "libgtk"
# Look for GTK in the user's Path as well as in some familiar locations
paths = [r'C:\GTK\bin', r'C:\GTK\lib', r'C:\Program Files\GTK\bin' r'C:\Program Files\GTK2-Runtime'] + os.environ['Path'].split(';')
for p in paths:
if not path.exists(p):
continue
files = [path.join(p, f) for f in os.listdir(p) if path.isfile(path.join(p, f)) and f.startswith(GTK_NAME)]
if len(files) > 0:
return p
raise Exception("""Could not find the GTK runtime.
Please place bin directory of your GTK installation in the program path.""")
def find_gtk_files():
def parent(dir_path):
return path.abspath(path.join(path.abspath(dir_path), '..'))
def strip_leading_path(leadingPath, p):
return p[len(leadingPath) + 1:]
data_files = []
gtk_path = parent(find_gtk_bin_directory())
for dir_path in [path.join(gtk_path, p) for p in ('etc', 'lib')]:
for dir_name, _, files in os.walk(dir_path):
files = [path.abspath(path.join(dir_name, f)) for f in files]
if len(files) > 0:
data_files.append((strip_leading_path(gtk_path, dir_name), files))
validPathList = [
path.join(gtk_path, 'share', 'aclocal'),
path.join(gtk_path, 'share', 'icons', iconsTheme),
path.join(gtk_path, 'share', 'themes', gtkTheme),
path.join(gtk_path, 'share', 'xml')]
if (not failLanguages):
for l in listLanguages:
validPathList.append(path.join(gtk_path, 'share', 'locale', l))
else:
validPathList.append(path.join(gtk_path, 'share', 'locale'))
for dir_name, _, files in os.walk(path.join(gtk_path, 'share')):
found = False
for v in validPathList:
if (dir_name.startswith(v)):
found = True
break
if (found):
files = [path.abspath(path.join(dir_name, f)) for f in files]
if len(files) > 0:
data_files.append((strip_leading_path(gtk_path, dir_name), files))
files_bin = []
for dir_name, _, files in os.walk(path.join(gtk_path, 'bin')):
for file in files:
if (file.endswith(".dll")):
files_bin += [path.abspath(path.join(gtk_path, 'bin', file))]
if (len(files_bin) > 0):
data_files.append((strip_leading_path(gtk_path, path.join(gtk_path, 'bin')), files_bin))
return data_files
def update_configuration(withReturn=False, withPath=False):
def parent(dir_path):
return path.abspath(path.join(path.abspath(dir_path), '..'))
def strip_leading_path(leadingPath, p):
return p[len(leadingPath) + 1:]
updateConfigAtEnd = withPath
xmlFiles = []
xmlFolder = path.join("share", "pycamimg", "xml")
dirXml = path.join ("src", xmlFolder)
files = os.listdir(dirXml)
for file in files:
if (path.isfile(path.join(dirXml, file))):
xmlFiles.append(path.abspath(path.join(dirXml, file)))
configFile = path.join("src", "share", "pycamimg", "config", "config.cfg")
config = ConfigParser.ConfigParser()
configMade = True
try:
# Try to read the config file
config .read([configFile])
except:
configMade = False
if ((configMade) and
(len(config .sections()) <= 0)):
configMade = False
if (configMade):
config.set("UI_CORE", "ui_files_as_resources", not withPath)
if (withPath):
config.set("UI_CORE", "xmlui_path", xmlFolder)
config.set("LOG", "level", 30)
else:
config.set("UI_CORE", "xmlui_path", "")
config.set("LOG", "level", 20)
try:
f = open(configFile, "w")
config.write(f)
except:
print("An error was ocurred when the configuration was saving")
finally:
# Checks the file status and closes it.
if (f != None):
f.close()
if (withReturn):
return [(xmlFolder, xmlFiles)]
else:
return None
def add_win32_options(options):
"""This function is responsible for finding data files and setting options necessary
to build executables and installers under Windows.
@return: A 2-tuple (data_files, options), where data_files is a list of Windows
specific data files (this would include the GTK binaries) and where
options are the options required by py2exe."""
if ((py2exe != None) and
('py2exe' in sys.argv or
'innosetup' in sys.argv or
'py2exe_nogtk' in sys.argv or
'innosetup_nogtk' in sys.argv)):
if (not (('py2exe_nogtk' in sys.argv) or ('innosetup_nogtk' in sys.argv))):
options['data_files'].extend(find_gtk_files())
uiData = update_configuration(withReturn=True, withPath=True)
if (uiData != None):
options['data_files'].extend(uiData)
py2exe_options = {
"packages": ["encodings", "pycamimg"],
"compressed": True,
"excludes": ["PyLucene", "Tkconstants", "Tkinter", "tcl", "translate.misc._csv"],
"dist_dir": path.join("dist", "win32"),
"includes" : ["cairo", "pango", "pangocairo", "atk", "gobject", "jpeg", "PIL", "PIL.ImageOps"],
"optimize": 2,
# "bundle_files": 1,
}
py2exe_options['includes'] += ["zipfile"] # Dependencies for the migration and auto-correction plug-ins, respectively.
innosetup_options = py2exe_options.copy()
options.update({
"windows": [
{
'script': __script__,
'icon_resources' : [(1, path.join("src", "share", "pycamimg", "icons", "pycamimg.ico"))]
}
],
"zipfile": "pycamimg.zip",
"options": {
"py2exe": py2exe_options,
"innosetup": innosetup_options
},
'cmdclass': {
"py2exe": buildExe,
"py2exe_nogtk": buildExe,
"innosetup": BuildWin32Installer,
"innosetup": BuildWin32Installer
}
})
options['scripts'].append("postinstall_win.py")
return options
def add_mac_options(options):
# http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#tweaking-your-info-plist
# http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html
if py2app is None:
return options
from translate.storage import factory
options.update({
"app": [__script__],
"options": {
"py2app": {
# "semi_standalone": True,
"compressed": True,
"argv_emulation": True,
"plist": {
"CFBundleGetInfoString": __description__,
"CFBundleGetInfoString": __name__,
"CFBundleIconFile": "%s.icns" % __filename__,
"CFBundleShortVersionString": __version__,
# "LSHasLocalizedDisplayName": "1",
# "LSMinimumSystemVersion": ???,
"NSHumanReadableCopyright": __copyright__,
"CFBundleDocumentTypes": [{
"CFBundleTypeExtensions": [extention.lstrip("*.") for extention in extentions],
"CFBundleTypeIconFile": "%s.icns" % __filename__,
"CFBundleTypeMIMETypes": mimetypes,
"CFBundleTypeName": description, # ????
} for description, extentions, mimetypes in factory.supported_files()]
}
}
}})
return options
def add_freedesktop_options(options):
return options
def add_platform_specific_options(options):
options = {
"scripts": [__script__],
"package_dir": {'':'src'},
"packages": __packages__,
"package_data": __package_data__,
"install_requires": __dependencies__,
"zip_safe": True,
"data_files": __data_files__
}
options.update({
"bdist":{
"formats" : "wininst,bztar,zip,egg",
"dist_dir": path.join("dist", "binary")
},
"sdist":{
"formats": "zip,bztar,gztar",
"dist_dir": path.join("dist", "sources")
},
"install":{
"optimize" : 2,
"compile" : True
}
}
)
if sys.platform == 'win32':
return add_win32_options(options)
if sys.platform == 'darwin':
return add_mac_options(options)
else:
return add_freedesktop_options(options)
def doSetup(options):
options = add_platform_specific_options(options)
setup(name=__name__,
version=__version__,
description=__description__,
author=__author__,
author_email=__email__,
maintainer=__author__,
maintainer_email=__email__,
url=__url__,
license=__license__,
platforms=["any"],
**options)
# if __name__ == "__main__":
try:
doSetup(options)
finally:
if (updateConfigAtEnd):
update_configuration()