"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup, Command
from glob import glob
import shutil
import syncplay

cmdlist = {}

APP = ['syncplayClient.py']
DATA_FILES = [
    ('resources', glob('resources/*.png') + glob('resources/*.rtf')),
]
OPTIONS = {
	'iconfile':'resources/icon.icns',
	'includes': {'PySide.QtCore', 'PySide.QtUiTools', 'PySide.QtGui'},
   	'plist': {
		'CFBundleName':'Syncplay',
		'CFBundleShortVersionString':syncplay.version,
		'CFBundleIdentifier':'pl.syncplay.Syncplay',
		'NSHumanReadableCopyright': '@ 2017 Syncplay All Rights Reserved'
	}
}

class Fix(Command):
    user_options = []
    
    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
    
    def trim_packages(self):
        """Remove big files in external dependencies that Syncplay doesn't need"""

        shutil.rmtree('dist/Syncplay.app/Contents/Frameworks/QtDesigner.framework', ignore_errors=True)
        shutil.rmtree('dist/Syncplay.app/Contents/Frameworks/QtScript.framework', ignore_errors=True)
        shutil.rmtree('dist/Syncplay.app/Contents/Frameworks/QtXml.framework', ignore_errors=True)

    def run(self):
        self.trim_packages()

cmdlist['fix'] = Fix

setup(
    app=APP,
    name='Syncplay',
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
    cmdclass=cmdlist
)
