# -*-mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-

import optparse
import os
import sys

import cx_Freeze
from cx_Freeze import cli

def main(constants):
    # options = cx_Freeze.ParseCommandLine()
    parser = cli.prepare_parser()
    args = cli.parse_command_line(parser)
    executables = [cx_Freeze.Executable(args.script,
                                        args.init_script,
                                        args.base_name,
                                        args.target_name,
                                        args.icon)
                  ]
    args.includes += ['wcwidth']
    args.excludes += ['numpy', 'sphinx', 'matplotlib', 'numpy', 'PyQt5', 'pandas', 'babel', 'wx', 'pythran', 'scipy', 'notebook', 'PySide2']
# 11704   cxFreeze-Pentoo/lib/sphinx/
# 14544   cxFreeze-Pentoo/lib/matplotlib/
# 18972   cxFreeze-Pentoo/lib/numpy/
# 21744   cxFreeze-Pentoo/lib/PyQt5/
# 29188   cxFreeze-Pentoo/lib/pandas/
# 29784   cxFreeze-Pentoo/lib/babel/
# 32468   cxFreeze-Pentoo/lib/wx/
# 36256   cxFreeze-Pentoo/lib/pythran/
# 49152   cxFreeze-Pentoo/lib/scipy/
# 218816  cxFreeze-Pentoo/lib/notebook/
# 407960  cxFreeze-Pentoo/lib/PySide2/
    args.zip_include_packages='*'
    args.zip_exclude_packages=''
    freezer = cx_Freeze.Freezer(executables,
                                includes=args.includes,
                                excludes=args.excludes,
                                packages=args.packages,
                                replacePaths=args.replace_paths,
                                compress=args.compress,
                                optimizeFlag=args.optimize_flag,
                                targetDir=args.target_dir,
                                includeFiles=args.include_files,
                                zipIncludes=args.zip_includes,
                                silent=args.silent,
                                zipIncludePackages=args.zip_include_packages,
                                zipExcludePackages=args.zip_exclude_packages,
                                )
    freezer.Freeze()
    return 0

if __name__ == '__main__':
    from cx_Freeze import freezer
    constants = freezer.ConstantsModule()
    try:
        i = main(constants)
    except KeyboardInterrupt:
        i =0
    sys.exit(i)
