makebundle.py 1.17 KB
Newer Older
1 2 3
#!/usr/bin/env python3
import os
import sys
4 5
from argparse import ArgumentParser
from subprocess import run, check_output, CalledProcessError
6 7 8 9 10 11

if __name__ == '__main__':
    if not os.path.isdir('mac'):
        sys.exit("can't find the 'mac' directory. make sure you run "
                 "this script from the project root")

12 13 14
    parser = ArgumentParser(description='Create a macOS .app bundle. '
                            'Requires PyInstaller and hdiutil (macOS).')
    parser.add_argument('--version', help='version number of the .app bundle')
15 16
    args = parser.parse_args()

17 18 19 20 21 22 23 24 25 26 27 28 29
    if args.version:
        version = args.version
    else:
        try:
            version = check_output(['git', 'describe', '--tags']).decode().strip()
        except CalledProcessError:
            version = 'unknown'
    dmg_name = 'gajim-{}.dmg'.format(version)

    run(['cp', 'mac/gajim.spec', 'gajim.spec'], check=True) # the .spec has to be in the project root
    run(['pyinstaller', 'gajim.spec'], check=True)
    run(['rm', '-rf', 'dist/launch']) # we only want Gajim.app in the dmg
    run(['hdiutil', 'create', '-volname', 'Gajim', '-srcfolder', 'dist', '-ov', '-format', 'UDZO', dmg_name], check=True)