| 1 |
#!hint/python3 |
| 2 |
|
| 3 |
""" |
| 4 |
PyInstaller hook to make mesonbuild include everything it needs to. |
| 5 |
""" |
| 6 |
|
| 7 |
import os |
| 8 |
from glob import glob |
| 9 |
|
| 10 |
from PyInstaller.utils.hooks import collect_data_files |
| 11 |
|
| 12 |
datas = [] |
| 13 |
hiddenimports = [] |
| 14 |
|
| 15 |
def get_all_modules_from_dir(dirname): |
| 16 |
''' |
| 17 |
Get all modules required for Meson itself from directories. |
| 18 |
''' |
| 19 |
modname = os.path.basename(dirname) |
| 20 |
modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))] |
| 21 |
modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')] |
| 22 |
return modules |
| 23 |
|
| 24 |
datas += collect_data_files('mesonbuild.scripts', include_py_files=True, excludes=['**/__pycache__']) |
| 25 |
datas += collect_data_files('mesonbuild.cmake.data') |
| 26 |
datas += collect_data_files('mesonbuild.dependencies.data') |
| 27 |
|
| 28 |
# lazy-loaded |
| 29 |
hiddenimports += get_all_modules_from_dir('mesonbuild/dependencies') |
| 30 |
# imported by meson.build files |
| 31 |
hiddenimports += get_all_modules_from_dir('mesonbuild/modules') |
| 32 |
# executed when named on CLI |
| 33 |
hiddenimports += get_all_modules_from_dir('mesonbuild/scripts') |
| 34 |
|
| 35 |
# Python packagers want to be minimal and only copy the things |
| 36 |
# that they can see being used. They are blind to many things. |
| 37 |
hiddenimports += [ |
| 38 |
# we run distutils as a subprocess via INTROSPECT_COMMAND. |
| 39 |
'distutils.archive_util', |
| 40 |
'distutils.cmd', |
| 41 |
'distutils.config', |
| 42 |
'distutils.core', |
| 43 |
'distutils.debug', |
| 44 |
'distutils.dep_util', |
| 45 |
'distutils.dir_util', |
| 46 |
'distutils.dist', |
| 47 |
'distutils.errors', |
| 48 |
'distutils.extension', |
| 49 |
'distutils.fancy_getopt', |
| 50 |
'distutils.file_util', |
| 51 |
'distutils.spawn', |
| 52 |
'distutils.util', |
| 53 |
'distutils.version', |
| 54 |
'distutils.command.build_ext', |
| 55 |
'distutils.command.build', |
| 56 |
'distutils.command.install', |
| 57 |
|
| 58 |
# needed for gtk's find_program() scripts |
| 59 |
'filecmp', |
| 60 |
] |