################################################################################ # import import os import sys import pytest import PySide2 import sysconfig from cx_Freeze import setup, Executable #, util ############################################################################### # Get Python stack PATH python_path = os.path.dirname(os.path.abspath(sys.executable)) if sys.platform != 'win32': # On windows plf, there is no 'bin' directory python_path = os.path.dirname(python_path) python_path = os.path.dirname(os.path.dirname(python_path)) ############################################################################### # Modules search paths setup_path = os.path.dirname(os.path.abspath(__file__)) ############################################################################### # Preparation of options ## Paths list path = sys.path ##################################################################### # Options d'inclusion/exclusion des modules # Add PySide2 directories pyside2_plugins = os.path.dirname(PySide2.__file__) if sys.platform != 'win32': # On windows plf, there is no 'Qt' directory pyside2_plugins = os.path.join(pyside2_plugins, 'Qt') pyside2_plugins = os.path.join(pyside2_plugins, 'plugins') pyside2_platforms = os.path.join(pyside2_plugins, 'platforms') pyside2_imageformats = os.path.join(pyside2_plugins, 'imageformats') includes = ['utils'] excludes = ['attr', 'cffi', 'cryptography', 'curses', 'distutils', 'lib2to3', 'more_itertools', 'numpy', 'packaging', 'pkg_resources', 'pluggy', 'py', 'pycparser', 'pydoc_data', 'pygments', 'pytz', 'setuptools', 'test', 'tkinter', 'unittest'] packages = [] include_files = [pyside2_platforms, pyside2_imageformats] zip_include_packages = ['PySide2', 'shiboken2'] ##################################################################### # Bug cx_freeze ################################################# # Add libffi-7.dll to fix: # from _ctypes import Union, Structure, Array # ImportError: DLL load failed while importing _ctypes: Le module spécifié est introuvable. if sys.platform == 'win32': include_files.append(os.path.join(os.path.dirname(os.path.abspath(sys.executable)), 'DLLs', 'libffi-7.dll')) ##################################################################### # Optimization level for bytecode compilation optimize = 0 silent = True ##################################################################### # Construction of the options dictionary options = { 'path': path, 'includes': includes, 'include_files': include_files, 'zip_include_packages': zip_include_packages, 'excludes': excludes, 'packages': packages, 'optimize': optimize, 'silent': silent } ##################################################################### # To include the necessary Windows dll system under Windows if sys.platform == 'win32': options['include_msvcr'] = False ############################################################################### # Preparation of targets base_console = None base_gui = None if sys.platform == 'win32': base_console = 'Console' base_gui = 'Win32GUI' ##################################################################### # Executables executables = list() ################################################# # Test test_cli = Executable( base = base_console, icon = None, script = 'test-cli.py', targetName = 'test-cli') executables.append(test_cli) test_gui = Executable( base = base_gui, icon = None, script = 'test-gui.py', targetName = 'test-gui') executables.append(test_gui) ############################################################################### # Creation of the setup setup(name = 'PythonFreeze', version = '1.0', description = 'Freeze All Python scripts', options = {'build_exe': options}, executables = executables)