~ubuntu-branches/ubuntu/trusty/miro/trusty

« back to all changes in this revision

Viewing changes to platform/windows-xul/setup.py

  • Committer: Daniel Hahler
  • Date: 2010-04-13 18:51:35 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: ubuntu-launchpad@thequod.de-20100413185135-xi24v1diqg8w406x
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Miro - an RSS based video player application
2
 
# Copyright (C) 2005-2009 Participatory Culture Foundation
 
2
# Copyright (C) 2005-2010 Participatory Culture Foundation
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
42
42
from distutils.core import Command
43
43
import distutils.command.install_data
44
44
from distutils.ccompiler import new_compiler
 
45
from distutils import file_util, dir_util
 
46
 
45
47
 
46
48
###############################################################################
47
49
## Paths and configuration                                                   ##
67
69
    print "Binary kit %s is missing.  Run 'setup_binarykit.sh'." % BINARY_KIT_ROOT
68
70
    sys.exit()
69
71
 
70
 
BOOST_ROOT = os.path.join(BINARY_KIT_ROOT, 'boost', 'win32')
71
 
BOOST_LIB_PATH = os.path.join(BOOST_ROOT, 'lib')
72
 
BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include')
73
 
BOOST_LIBRARIES = [os.path.splitext(os.path.basename(f))[0] for f in
74
 
        glob(os.path.join(BOOST_LIB_PATH, '*.lib'))]
75
 
 
76
72
ZLIB_INCLUDE_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'include')
77
73
ZLIB_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'lib')
78
74
ZLIB_RUNTIME_LIBRARY_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib')
81
77
OPENSSL_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'openssl', 'lib')
82
78
OPENSSL_LIBRARIES = ['ssleay32', 'libeay32']
83
79
 
84
 
GTK_ROOT_PATH = os.path.join(BINARY_KIT_ROOT, 'gtk+-2.14.7-bundle')
 
80
GTK_ROOT_PATH = os.path.join(BINARY_KIT_ROOT, 'gtk+-bundle_2.16.6-20091215_win32')
85
81
GTK_INCLUDE_PATH = os.path.join(GTK_ROOT_PATH, 'include')
86
82
GTK_LIB_PATH = os.path.join(GTK_ROOT_PATH, 'lib')
87
83
GTK_BIN_PATH = os.path.join(GTK_ROOT_PATH, 'bin')
88
84
GTK_INCLUDE_DIRS = [
89
 
        os.path.join(GTK_INCLUDE_PATH, 'atk-1.0'),
90
 
        os.path.join(GTK_INCLUDE_PATH, 'gtk-2.0'),
91
 
        os.path.join(GTK_INCLUDE_PATH, 'glib-2.0'),
92
 
        os.path.join(GTK_INCLUDE_PATH, 'glib-2.0'),
93
 
        os.path.join(GTK_INCLUDE_PATH, 'pango-1.0'),
94
 
        os.path.join(GTK_INCLUDE_PATH, 'cairo'),
95
 
        os.path.join(GTK_LIB_PATH, 'glib-2.0', 'include'),
96
 
        os.path.join(GTK_LIB_PATH, 'gtk-2.0', 'include'),
 
85
    os.path.join(GTK_INCLUDE_PATH, 'atk-1.0'),
 
86
    os.path.join(GTK_INCLUDE_PATH, 'gtk-2.0'),
 
87
    os.path.join(GTK_INCLUDE_PATH, 'glib-2.0'),
 
88
    os.path.join(GTK_INCLUDE_PATH, 'glib-2.0'),
 
89
    os.path.join(GTK_INCLUDE_PATH, 'pango-1.0'),
 
90
    os.path.join(GTK_INCLUDE_PATH, 'cairo'),
 
91
    os.path.join(GTK_LIB_PATH, 'glib-2.0', 'include'),
 
92
    os.path.join(GTK_LIB_PATH, 'gtk-2.0', 'include'),
97
93
]
98
94
 
99
95
PYGOBJECT_INCLUDE_DIR = os.path.join(BINARY_KIT_ROOT, 'pygobject')
100
96
 
101
 
# Path to the Mozilla "xulrunner-sdk" distribution. We include a build in
102
 
# the Binary Kit to save you a minute or two, but if you want to be
 
97
# Path to the Mozilla "xulrunner-sdk" distribution. We include a build
 
98
# in the Binary Kit to save you a minute or two, but if you want to be
103
99
# more up-to-date, nightlies are available from Mozilla at:
104
100
# http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/
105
101
XULRUNNER_SDK_PATH = os.path.join(BINARY_KIT_ROOT, 'xulrunner-sdk')
151
147
portable_dir = os.path.join(root_dir, 'portable')
152
148
portable_widgets_dir = os.path.join(portable_dir, 'frontends', 'widgets')
153
149
portable_xpcom_dir = os.path.join(portable_widgets_dir, 'gtk', 'xpcom')
 
150
test_dir = os.path.join(root_dir, 'resources')
154
151
resources_dir = os.path.join(root_dir, 'resources')
 
152
 
155
153
sys.path.insert(0, root_dir)
156
 
# when we install the portable modules, they will be in the miro package, but
157
 
# at this point, they are in a package named "portable", so let's hack it
 
154
# when we install the portable modules, they will be in the miro
 
155
# package, but at this point, they are in a package named "portable",
 
156
# so let's hack it
158
157
import portable
159
158
sys.modules['miro'] = portable
160
159
 
164
163
 
165
164
#### Extensions ####
166
165
 
167
 
sorts_ext = Extension("miro.sorts", 
168
 
        sources=[os.path.join(root_dir, 'portable', 'sorts.pyx')])
169
 
 
170
 
fasttypes_ext = Extension("miro.fasttypes", 
171
 
        sources=[os.path.join(root_dir, 'portable', 'fasttypes.cpp')],
172
 
        library_dirs=[BOOST_LIB_PATH],
173
 
        include_dirs=[BOOST_INCLUDE_PATH]
174
 
        )
175
 
 
176
 
pygtkhacks_ext = Extension("miro.frontends.widgets.gtk.pygtkhacks",
177
 
        sources=[
178
 
            os.path.join(portable_widgets_dir, 'gtk', 'pygtkhacks.pyx'),
 
166
pygtkhacks_ext = Extension(
 
167
    "miro.frontends.widgets.gtk.pygtkhacks",
 
168
    sources=[
 
169
        os.path.join(portable_widgets_dir, 'gtk', 'pygtkhacks.pyx'),
179
170
        ],
180
 
        include_dirs=GTK_INCLUDE_DIRS + [PYGOBJECT_INCLUDE_DIR],
181
 
        library_dirs=[GTK_LIB_PATH],
182
 
        libraries=[
183
 
            'gtk-win32-2.0',
184
 
        ])
 
171
    include_dirs=GTK_INCLUDE_DIRS + [PYGOBJECT_INCLUDE_DIR],
 
172
    library_dirs=[GTK_LIB_PATH],
 
173
    libraries=[
 
174
        'gtk-win32-2.0',
 
175
        ]
 
176
    )
185
177
 
186
178
xulrunnerbrowser_ext_dir = os.path.join(widgets_dir, 'XULRunnerBrowser')
187
 
xulrunnerbrowser_ext = Extension("miro.plat.frontends.widgets.xulrunnerbrowser",
188
 
        include_dirs=[
189
 
            os.path.join(XULRUNNER_SDK_PATH, 'sdk', 'include'),
190
 
            os.path.join(XULRUNNER_SDK_PATH, 'include'),
191
 
            os.path.join(XULRUNNER_SDK_PATH, 'include', 'xpcom'),
192
 
            portable_xpcom_dir,
 
179
xulrunnerbrowser_ext = Extension(
 
180
    "miro.plat.frontends.widgets.xulrunnerbrowser",
 
181
    include_dirs=[
 
182
        os.path.join(XULRUNNER_SDK_PATH, 'sdk', 'include'),
 
183
        os.path.join(XULRUNNER_SDK_PATH, 'include'),
 
184
        os.path.join(XULRUNNER_SDK_PATH, 'include', 'xpcom'),
 
185
        portable_xpcom_dir,
193
186
        ] + GTK_INCLUDE_DIRS,
194
 
        define_macros=[
195
 
            ("XP_WIN", 1), 
196
 
            ("XPCOM_GLUE", 1),
197
 
            ("PCF_USING_XULRUNNER19", 1),
198
 
        ],
199
 
        library_dirs=[
200
 
            os.path.join(XULRUNNER_SDK_PATH, 'lib'),
201
 
            GTK_LIB_PATH,
202
 
        ],
203
 
        libraries=[
204
 
            'xpcomglue',
205
 
            'xul',
206
 
            'user32',
207
 
            'gdk-win32-2.0',
208
 
            'gtk-win32-2.0',
209
 
        ],
210
 
        language="c++",
211
 
        sources = [
212
 
            os.path.join(xulrunnerbrowser_ext_dir, 'xulrunnerbrowser.pyx'),
213
 
            os.path.join(portable_xpcom_dir, 'HttpObserver.cc'),
214
 
            os.path.join(xulrunnerbrowser_ext_dir, 'MiroBrowserEmbed.cpp'),
215
 
            os.path.join(xulrunnerbrowser_ext_dir, 'MiroWindowCreator.cpp'),
216
 
            os.path.join(xulrunnerbrowser_ext_dir, 'FixFocus.cpp'),
217
 
            os.path.join(xulrunnerbrowser_ext_dir, 'Init.cpp'),
218
 
            ]
219
 
        )
 
187
    define_macros=[
 
188
        ("XP_WIN", 1), 
 
189
        ("XPCOM_GLUE", 1),
 
190
        ("PCF_USING_XULRUNNER19", 1),
 
191
        ],
 
192
    library_dirs=[
 
193
        os.path.join(XULRUNNER_SDK_PATH, 'lib'),
 
194
        GTK_LIB_PATH,
 
195
        ],
 
196
    libraries=[
 
197
        'xpcomglue',
 
198
        'xul',
 
199
        'user32',
 
200
        'gdk-win32-2.0',
 
201
        'gtk-win32-2.0',
 
202
        ],
 
203
    language="c++",
 
204
    sources=[
 
205
        os.path.join(xulrunnerbrowser_ext_dir, 'xulrunnerbrowser.pyx'),
 
206
        os.path.join(portable_xpcom_dir, 'HttpObserver.cc'),
 
207
        os.path.join(xulrunnerbrowser_ext_dir, 'MiroBrowserEmbed.cpp'),
 
208
        os.path.join(xulrunnerbrowser_ext_dir, 'MiroWindowCreator.cpp'),
 
209
        os.path.join(xulrunnerbrowser_ext_dir, 'FixFocus.cpp'),
 
210
        os.path.join(xulrunnerbrowser_ext_dir, 'Init.cpp'),
 
211
        ]
 
212
    )
220
213
 
221
214
# Setting the path here allows py2exe to find the DLLS
222
215
os.environ['PATH'] = ';'.join([
223
 
    OPENSSL_LIB_PATH, BOOST_LIB_PATH, ZLIB_RUNTIME_LIBRARY_PATH, 
224
 
    LIBTORRENT_PATH, GTK_BIN_PATH, os.environ['PATH']])
 
216
        OPENSSL_LIB_PATH, ZLIB_RUNTIME_LIBRARY_PATH, 
 
217
        LIBTORRENT_PATH, GTK_BIN_PATH, os.environ['PATH']])
225
218
 
226
219
# Private extension modules to build.
227
220
ext_modules = [
228
 
    fasttypes_ext,
229
 
    sorts_ext,
230
221
    pygtkhacks_ext,
231
222
    xulrunnerbrowser_ext,
232
223
]
250
241
    data_files.extend(find_data_files(path, src_path))
251
242
 
252
243
data_files.append(('', iglob(os.path.join(GTK_BIN_PATH, '*.dll'))))
253
 
data_files.extend(find_data_files('vlc-plugins', 
254
 
    os.path.join(VLC_PATH, 'vlc-plugins')))
 
244
data_files.extend(find_data_files(
 
245
        'vlc-plugins', os.path.join(VLC_PATH, 'vlc-plugins')))
255
246
data_files.append(('', [os.path.join(VLC_PATH, 'libvlc.dll')]))
256
247
data_files.append(('', [os.path.join(VLC_PATH, 'libvlccore.dll')]))
257
248
data_files.append(('', [os.path.join(LIBTORRENT_PATH, 'libtorrent.pyd')]))
258
 
# data_files.append(('', [os.path.join(OPENSSL_LIB_PATH, 'libeay32.dll')]))
259
 
# data_files.append(('', [os.path.join(OPENSSL_LIB_PATH, 'ssleay32.dll')]))
260
249
 
261
250
# handle the resources subdirectories.
262
251
for dir in ('searchengines', 'images'):
268
257
 
269
258
locale_temp_dir = os.path.join(os.path.dirname(__file__), "build", "locale")
270
259
 
271
 
# handle locale files
272
 
for source in glob(os.path.join(resources_dir, "locale", "*.mo")):
273
 
    lang = os.path.basename(source)[:-3]
274
 
    dest = os.path.join(locale_temp_dir, lang, "LC_MESSAGES", "miro.mo")
275
 
    try:
276
 
        os.makedirs(os.path.dirname(dest))
277
 
    except WindowsError:
278
 
        pass
279
 
    shutil.copyfile(source, dest)
280
 
 
 
260
def copy_locale_files():
 
261
    print "*** copying locale files ***"
 
262
    # handle locale files
 
263
    locale_files = []
 
264
    for source in glob(os.path.join(resources_dir, "locale", "*.mo")):
 
265
        lang = os.path.basename(source)[:-3]
 
266
        dest = os.path.join(locale_temp_dir, lang, "LC_MESSAGES", "miro.mo")
 
267
        locale_files.append((source, dest))
 
268
 
 
269
    dir_util.create_tree(os.path.dirname(__file__), [dst for src, dst in locale_files])
 
270
 
 
271
    for source, dest in locale_files:
 
272
        file_util.copy_file(source, dest, update=True, verbose=True)
 
273
 
 
274
# FIXME - this should be done inside a build command
 
275
copy_locale_files()
281
276
data_files.extend(find_data_files(os.path.join("resources", "locale"),
282
277
                                  locale_temp_dir))
283
278
 
286
281
 
287
282
# pixmap for the about dialog
288
283
icon_path = os.path.join("icons", "hicolor", "128x128", "apps")
289
 
data_files.append((os.path.join("resources", icon_path), [os.path.join(platform_dir, icon_path, "miro.png")]))
 
284
data_files.append((os.path.join("resources", icon_path), 
 
285
                   [os.path.join(platform_dir, icon_path, "miro.png")]))
290
286
 
291
 
###############################################################################
 
287
###########################################################################
292
288
 
293
289
#### Our specialized install_data command ####
294
290
class install_data(distutils.command.install_data.install_data):
295
 
    """install_data extends to default implementation so that it automatically
296
 
    installs app.config from app.config.template.
 
291
    """install_data extends to default implementation so that it
 
292
    automatically installs app.config from app.config.template.
297
293
    """
298
294
 
299
295
    def install_app_config(self):
312
308
        print "Using %s" % revisionnum
313
309
 
314
310
        self.mkpath(os.path.dirname(dest))
315
 
        # We don't use the dist utils copy_file() because it only copies
316
 
        # the file if the timestamp is newer
 
311
        # We don't use the dist utils copy_file() because it only
 
312
        # copies the file if the timestamp is newer
317
313
        fill_template(template, dest,
318
314
            APP_REVISION=revision,
319
315
            APP_REVISION_NUM=revisionnum,
329
325
        source = os.path.join(GTK_ROOT_PATH, basename)
330
326
        dest = os.path.join(self.install_dir, basename)
331
327
        contents = open(source).read()
332
 
        # Not sure why they have paths like this in the file, but we need to
333
 
        # change them.
334
 
        contents = contents.replace("c:/devel/target/9c384abfa28a3e070eb60fc2972f823b/",
335
 
                "")
 
328
        # Not sure why they have paths like this in the file, but we
 
329
        # need to change them.
 
330
        contents = contents.replace(
 
331
            "c:/devel/target/9c384abfa28a3e070eb60fc2972f823b/", "")
336
332
        self.mkpath(os.path.dirname(dest))
337
333
        open(dest, 'wt').write(contents)
338
334
        self.outfiles.append(dest)
346
342
# Recipe taken from
347
343
# http://www.py2exe.org/index.cgi/OverridingCriteraForIncludingDlls
348
344
DLLS_TO_INCLUDE = [
349
 
        'msvcp71.dll',
 
345
    'msvcp71.dll',
350
346
]
351
347
origIsSystemDLL = py2exe.build_exe.isSystemDLL
352
348
def isSystemDLL(pathname):
373
369
 
374
370
    def copy_ico(self):
375
371
        dist_dir = self.get_finalized_command('py2exe').dist_dir
376
 
        self.copy_file("Miro.ico", os.path.join(dist_dir, "%s.ico" % template_vars['shortAppName']))
 
372
        shortappname = template_vars["shortAppName"]
 
373
        self.copy_file("Miro.ico", 
 
374
                       os.path.join(dist_dir, "%s.ico" % shortappname))
 
375
 
 
376
class bdist_test(Command):
 
377
    description = "Builds Miro with unit tests"
 
378
 
 
379
    user_options = []
 
380
 
 
381
    def initialize_options(self):
 
382
        pass
 
383
 
 
384
    def finalize_options(self):
 
385
        pass
 
386
 
 
387
    def run(self):
 
388
        self.run_command('bdist_miro')
 
389
        self.copy_test_data()
 
390
 
 
391
    def copy_test_data(self):
 
392
        # copy test data over
 
393
        dist_dir = self.get_finalized_command('py2exe').dist_dir
 
394
 
 
395
        self.copy_tree(os.path.join(resources_dir, 'testdata'),
 
396
                       os.path.join(dist_dir, 'resources', 'testdata'))
377
397
 
378
398
class runmiro(Command):
379
399
    description = "build Miro and start it up"
396
416
class bdist_nsis(Command):
397
417
    description = "create Miro installer using NSIS"
398
418
 
399
 
    user_options = [('generic', None, 'Build a generic installer instead of the Miro-branded installer.'),
400
 
                    ('install-icon=', None, 'ICO file to use for the installer.'),
401
 
                    ('install-image=', None, 'BMP file to use for the welcome/finish pages.')]
 
419
    user_options = [
 
420
        ('generic', None, 'Build a generic installer instead of the Miro-branded installer.'),
 
421
        ('install-icon=', None, 'ICO file to use for the installer.'),
 
422
        ('install-image=', None, 'BMP file to use for the welcome/finish pages.')
 
423
        ]
402
424
 
403
425
    def initialize_options(self):
404
426
        self.generic = False
407
429
 
408
430
    def finalize_options(self):
409
431
        if self.generic and (self.install_icon or self.install_icon):
410
 
            raise AssertionError('cannot specify install images with generic installer')
 
432
            raise AssertionError("cannot specify install images with "
 
433
                                 "generic installer")
411
434
        if self.generic:
412
435
            self.install_icon = 'miro-installer-generic.ico'
413
436
            self.install_image = 'miro-install-generic.bmp'
429
452
        self.copy_file("askBarSetup-4.1.0.2.exe", self.dist_dir)
430
453
        self.copy_file("ask_toolbar.bmp", self.dist_dir)
431
454
 
432
 
        nsisVars = {}
433
 
        for (ourName, nsisName) in [
434
 
                ('appVersion', 'CONFIG_VERSION'),
435
 
                ('projectURL', 'CONFIG_PROJECT_URL'),
436
 
                ('shortAppName', 'CONFIG_SHORT_APP_NAME'),
437
 
                ('longAppName', 'CONFIG_LONG_APP_NAME'),
438
 
                ('publisher', 'CONFIG_PUBLISHER')]:
439
 
            nsisVars[nsisName] = template_vars[ourName]
 
455
        nsis_vars = {}
 
456
        for our_name, nsis_name in [('appVersion', 'CONFIG_VERSION'),
 
457
                                    ('projectURL', 'CONFIG_PROJECT_URL'),
 
458
                                    ('shortAppName', 'CONFIG_SHORT_APP_NAME'),
 
459
                                    ('longAppName', 'CONFIG_LONG_APP_NAME'),
 
460
                                    ('publisher', 'CONFIG_PUBLISHER')]:
 
461
            nsis_vars[nsis_name] = template_vars[our_name]
440
462
 
441
 
        nsisVars['CONFIG_EXECUTABLE'] = "%s.exe" % template_vars['shortAppName']
442
 
        nsisVars['CONFIG_DOWNLOADER_EXECUTABLE'] = "%s_Downloader.exe" % \
443
 
                template_vars['shortAppName']
444
 
        nsisVars['CONFIG_MOVIE_DATA_EXECUTABLE'] = "%s_MovieData.exe" % \
445
 
                template_vars['shortAppName']
446
 
        nsisVars['CONFIG_ICON'] = "%s.ico" % template_vars['shortAppName']
447
 
        nsisVars['CONFIG_PROG_ID'] = template_vars['longAppName'].replace(" ", ".") + ".1"
448
 
        nsisVars['MIRO_INSTALL_ICON'] = self.install_icon
449
 
        nsisVars['MIRO_INSTALL_IMAGE'] = self.install_image
450
 
        nsisVars['CONFIG_BINARY_KIT'] = BINARY_KIT_ROOT
 
463
        nsis_vars['CONFIG_EXECUTABLE'] = "%s.exe" % template_vars['shortAppName']
 
464
        nsis_vars['CONFIG_DOWNLOADER_EXECUTABLE'] = "%s_Downloader.exe" % \
 
465
                template_vars['shortAppName']
 
466
        nsis_vars['CONFIG_MOVIE_DATA_EXECUTABLE'] = "%s_MovieData.exe" % \
 
467
                template_vars['shortAppName']
 
468
        nsis_vars['CONFIG_ICON'] = "%s.ico" % template_vars['shortAppName']
 
469
        nsis_vars['CONFIG_PROG_ID'] = template_vars['longAppName'].replace(" ", ".") + ".1"
 
470
        nsis_vars['MIRO_INSTALL_ICON'] = self.install_icon
 
471
        nsis_vars['MIRO_INSTALL_IMAGE'] = self.install_image
 
472
        nsis_vars['CONFIG_BINARY_KIT'] = BINARY_KIT_ROOT
451
473
        if self.generic:
452
 
            nsisVars['GENERIC_INSTALLER'] = '1'
 
474
            nsis_vars['GENERIC_INSTALLER'] = '1'
453
475
 
454
476
        # One stage installer
455
477
        if self.generic:
456
 
            outputFile = "%s-%s-generic.exe"
 
478
            output_file = "%s-%s-generic.exe"
457
479
        else:
458
 
            outputFile = "%s-%s.exe"
459
 
        outputFile = outputFile % \
460
 
                (template_vars['shortAppName'], template_vars['appVersion'])
461
 
        nsisVars['CONFIG_OUTPUT_FILE'] = outputFile
462
 
        nsisVars['CONFIG_TWOSTAGE'] = "No"
463
 
 
464
 
        nsisArgs = ["/D%s=%s" % (k, v) for (k, v) in nsisVars.iteritems()]
465
 
        nsisArgs.append(os.path.join(self.dist_dir, "Miro.nsi"))
466
 
 
467
 
        if os.access(outputFile, os.F_OK):
468
 
            os.remove(outputFile)
469
 
        if subprocess.call([NSIS_PATH] + nsisArgs) != 0:
 
480
            output_file = "%s-%s.exe"
 
481
        output_file = (output_file % 
 
482
                       (template_vars['shortAppName'], template_vars['appVersion']))
 
483
        nsis_vars['CONFIG_OUTPUT_FILE'] = output_file
 
484
        nsis_vars['CONFIG_TWOSTAGE'] = "No"
 
485
 
 
486
        nsis_args = ["/D%s=%s" % (k, v) for (k, v) in nsis_vars.iteritems()]
 
487
        nsis_args.append(os.path.join(self.dist_dir, "Miro.nsi"))
 
488
 
 
489
        if os.access(output_file, os.F_OK):
 
490
            os.remove(output_file)
 
491
        if subprocess.call([NSIS_PATH] + nsis_args) != 0:
470
492
            print "ERROR creating the 1 stage installer, quitting"
471
493
            return
472
494
 
473
495
        # Two stage installer
474
496
        if self.generic:
475
 
            outputFile = '%s-%s-generic-twostage.exe'
 
497
            output_file = '%s-%s-generic-twostage.exe'
476
498
        else:
477
 
            outputFile = "%s-%s-twostage.exe"
478
 
        outputFile = outputFile % \
479
 
            (template_vars['shortAppName'], template_vars['appVersion'])
480
 
        nsisVars['CONFIG_OUTPUT_FILE'] = outputFile
481
 
        nsisVars['CONFIG_TWOSTAGE'] = "Yes"
482
 
 
483
 
        nsisArgs = ["/D%s=%s" % (k, v) for (k, v) in nsisVars.iteritems()]
484
 
        nsisArgs.append(os.path.join(self.dist_dir, "Miro.nsi"))
485
 
 
486
 
        if os.access(outputFile, os.F_OK):
487
 
            os.remove(outputFile)
488
 
        subprocess.call([NSIS_PATH] + nsisArgs)
 
499
            output_file = "%s-%s-twostage.exe"
 
500
        output_file = (output_file % 
 
501
                       (template_vars['shortAppName'], template_vars['appVersion']))
 
502
        nsis_vars['CONFIG_OUTPUT_FILE'] = output_file
 
503
        nsis_vars['CONFIG_TWOSTAGE'] = "Yes"
 
504
 
 
505
        nsis_args = ["/D%s=%s" % (k, v) for (k, v) in nsis_vars.iteritems()]
 
506
        nsis_args.append(os.path.join(self.dist_dir, "Miro.nsi"))
 
507
 
 
508
        if os.access(output_file, os.F_OK):
 
509
            os.remove(output_file)
 
510
        subprocess.call([NSIS_PATH] + nsis_args)
489
511
 
490
512
        zip_path = os.path.join(self.dist_dir, "%s-Contents-%s.zip" %
491
 
            (template_vars['shortAppName'],template_vars['appVersion']))
 
513
            (template_vars['shortAppName'], template_vars['appVersion']))
492
514
        self.zipfile = zip.ZipFile(zip_path, 'w', zip.ZIP_DEFLATED)
493
 
        self.addFile(nsisVars['CONFIG_EXECUTABLE'])
494
 
        self.addFile(nsisVars['CONFIG_ICON'])
495
 
        self.addFile(nsisVars['CONFIG_MOVIE_DATA_EXECUTABLE'])
496
 
        self.addGlob("*.dll")
 
515
        self.add_file(nsis_vars['CONFIG_EXECUTABLE'])
 
516
        self.add_file(nsis_vars['CONFIG_ICON'])
 
517
        self.add_file(nsis_vars['CONFIG_MOVIE_DATA_EXECUTABLE'])
 
518
        self.add_glob("*.dll")
497
519
 
498
 
        self.addDirectory("defaults")
499
 
        self.addDirectory("resources")
500
 
        self.addDirectory("xulrunner")
 
520
        self.add_directory("defaults")
 
521
        self.add_directory("resources")
 
522
        self.add_directory("xulrunner")
501
523
 
502
524
        self.zipfile.close()
503
525
 
504
 
    def addGlob(self, wildcard):
 
526
    def add_glob(self, wildcard):
505
527
        wildcard = os.path.join(self.dist_dir, wildcard)
506
528
        length = len(self.dist_dir)
507
529
        for filename in iglob(wildcard):
508
530
            if filename[:length] == self.dist_dir:
509
531
                filename = filename[length:]
510
 
                while len(filename) > 0 and (filename[0] == '/' or filename[0] == '\\'):
 
532
                while (len(filename) > 0 
 
533
                       and (filename[0] == '/' or filename[0] == '\\')):
511
534
                    filename = filename[1:]
512
535
            print "Compressing %s" % filename
513
536
            self.zipfile.write(os.path.join(self.dist_dir, filename), filename)
514
537
 
515
 
    def addFile(self, filename):
 
538
    def add_file(self, filename):
516
539
        length = len(self.dist_dir)
517
540
        if filename[:length] == self.dist_dir:
518
541
            filename = filename[length:]
519
 
            while len(filename) > 0 and (filename[0] == '/' or filename[0] == '\\'):
 
542
            while (len(filename) > 0 
 
543
                   and (filename[0] == '/' or filename[0] == '\\')):
520
544
                filename = filename[1:]
521
545
        print "Compressing %s" % filename
522
546
        self.zipfile.write(os.path.join(self.dist_dir, filename), filename)
523
547
 
524
 
    def addDirectory(self, dirname):
 
548
    def add_directory(self, dirname):
525
549
        for root, dirs, files in os.walk(os.path.join(self.dist_dir, dirname)):
526
550
            for name in files:
527
 
                self.addFile(os.path.join(root, name))
 
551
                self.add_file(os.path.join(root, name))
528
552
 
529
553
if __name__ == "__main__":
530
554
    setup(
533
557
                'script': 'Miro.py',
534
558
                'dest_base': template_vars['shortAppName'],
535
559
                'icon_resources': [(0, "Miro.ico")],
536
 
            },
 
560
                },
537
561
            {
538
562
                'script': 'Miro_Downloader.py',
539
563
                'dest_base': '%s_Downloader' % template_vars['shortAppName'],
540
564
                'icon_resources': [(0, "Miro.ico")],
541
 
            },
542
 
        ],
 
565
                },
 
566
            ],
543
567
        console=[
544
568
            {
545
569
                'script': 'moviedata_util.py',
546
570
                'dest_base': '%s_MovieData' % template_vars['shortAppName'],
547
571
                'icon_resources': [(0, "Miro.ico")],
548
 
            },
549
 
        ],
 
572
                },
 
573
            {
 
574
                'script': 'mirotest.py',
 
575
                'dest_base': 'mirotest',
 
576
                'icon_resources': [(0, "Miro.ico")],
 
577
                }
 
578
            ],
550
579
        ext_modules=ext_modules,
551
580
        packages=[
552
581
            'miro',
555
584
            'miro.frontends',
556
585
            'miro.frontends.widgets',
557
586
            'miro.frontends.widgets.gtk',
 
587
            'miro.test',
558
588
            'miro.plat',
559
589
            'miro.plat.renderers',
560
590
            'miro.plat.frontends',
561
591
            'miro.plat.frontends.widgets',
562
 
        ],
 
592
            ],
563
593
        package_dir={
564
594
            'miro': portable_dir,
565
595
            'miro.plat': platform_package_dir,
566
 
        },
 
596
            },
567
597
        data_files=data_files,
568
598
        cmdclass={
569
599
            'build_ext': build_ext,
570
600
            'install_data': install_data,
571
601
            'bdist_miro': bdist_miro,
572
602
            'bdist_nsis': bdist_nsis,
 
603
            'bdist_test': bdist_test,
573
604
            'runmiro': runmiro,
574
 
        },
 
605
            },
575
606
        options={
576
607
            'py2exe': {
577
608
                'packages': [
578
609
                    'encodings',
579
610
                    ],
580
611
                'includes': 'cairo, pango, pangocairo, atk, gobject, libtorrent',
 
612
                },
581
613
            },
582
 
        },
583
 
    )
 
614
        )