File indexing completed on 2024-04-28 07:51:11

0001 """
0002 
0003 Copyright (C) 2008-2016 Wolfgang Rohdewald <wolfgang@rohdewald.de>
0004 
0005 SPDX-License-Identifier: GPL-2.0
0006 
0007 
0008 
0009 
0010 This is to be executed on windows.
0011 The directory 'share' must already be filled.
0012 That can be done with winprep.py which should run
0013 on linux in the src directory with Kajongg fully installed.
0014 
0015 Usage: see ../README.windows
0016 """
0017 
0018 # pylint: disable=wrong-import-order, wrong-import-position, import-error
0019 
0020 # ==== adapt this part =====
0021 FULLAUTHOR = "Wolfgang Rohdewald <wolfgang@rohdewald.de>"
0022 LICENSE = 'GNU General Public License v2'
0023 URL = "https://apps.kde.org/kajongg"
0024 try:
0025     from appversion import VERSION
0026 except ImportError:
0027     VERSION = "Unknown"
0028 # ==========================
0029 
0030 import os
0031 import sys
0032 import re
0033 import msilib
0034 from shutil import rmtree
0035 
0036 from cx_Freeze import setup, Executable
0037 
0038 (AUTHOR, EMAIL) = re.match(r'^(.*?)\s*<(.*)>$', FULLAUTHOR).groups()
0039 
0040 # pylint: disable=invalid-name
0041 
0042 if os.path.exists('build'):
0043     rmtree('build')
0044 
0045 includes = [
0046     "zope.interface",
0047     "twisted.internet",
0048     "twisted.internet.protocol",
0049     "pkg_resources"]
0050 packages = []
0051 namespace_packages = ["zope"]
0052 include_files = ('share', os.path.join(sys.base_prefix, 'DLLs', 'sqlite3.dll'))
0053 
0054 excludes = ['tcl', 'tk', 'ttk', 'tkinter', 'Tkconstants', 'Tkinter']
0055 # strangely, excluding modules does not get rid of warnings about missing
0056 # modules
0057 
0058 build_exe_options = {
0059     "packages": packages, "excludes": excludes, "includes": includes,
0060     "include_files": include_files,
0061     "namespace_packages": namespace_packages, 'silent': False}
0062 
0063 kajExe = Executable('kajongg.py', icon='kajongg.ico', base='Win32GUI',
0064                     shortcutName='kajongg', shortcutDir='ProgramMenuFolder')
0065 kajServer = Executable('kajonggserver.py', icon='kajongg.ico')
0066 executables = [kajExe, kajServer]
0067 
0068 
0069 from cx_Freeze import windist
0070 
0071 
0072 class bdist_msi(windist.bdist_msi):
0073 
0074     """we add an icon for the uninstaller"""
0075 
0076     def productcode(self):
0077         """get our productcode"""
0078         view = self.db.OpenView(
0079             "SELECT Value FROM Property WHERE Property = 'ProductCode'")
0080         view.Execute(None)
0081         record = view.Fetch()
0082         result = record.GetString(1)
0083         view.Close()
0084         return result
0085 
0086     def add_config(self, fullname):
0087         """add the uninstaller icon"""
0088         windist.bdist_msi.add_config(self, fullname)
0089         msilib.add_data(self.db, "Registry", [("DisplayIcon",  # Registry
0090                                                -1,  # Root
0091                                                r"Software\Microsoft\Windows\CurrentVersion\Uninstall\%s" %
0092                                                self.productcode(),  # Key
0093                                                "DisplayIcon",  # Name
0094                                                r"[icons]kajongg.ico",  # Value
0095                                                "TARGETDIR")])  # default Component
0096 
0097 setup(
0098     cmdclass={'bdist_msi': bdist_msi},  # define custom build class
0099     name='kajongg',
0100     version=VERSION,
0101     description='The classical game of Mah Jongg',
0102     long_description="This is the classical Mah Jongg for four players. "
0103     "If you are looking for the Mah Jongg solitaire please use the "
0104     "application kmahjongg.",
0105     author=AUTHOR,
0106     author_email=EMAIL,
0107     url=URL,
0108     download_url='https://www.linux-apps.com/p/1109453/',
0109     options={"build_exe": build_exe_options},
0110     executables=executables,
0111     license=LICENSE)