summaryrefslogtreecommitdiff
path: root/packaging/hook-mesonbuild.py
blob: b076c506d17c700d5910f0706dc4ccb51b04f1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!hint/python3

"""
PyInstaller hook to make mesonbuild include everything it needs to.
"""

import os
from glob import glob

from PyInstaller.utils.hooks import collect_data_files

datas = []
hiddenimports = []

def get_all_modules_from_dir(dirname):
    '''
    Get all modules required for Meson itself from directories.
    '''
    modname = os.path.basename(dirname)
    modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))]
    modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')]
    return modules

datas += collect_data_files('mesonbuild.scripts')
datas += collect_data_files('mesonbuild.cmake.data')
datas += collect_data_files('mesonbuild.dependencies.data')

hiddenimports += get_all_modules_from_dir('mesonbuild/modules')
hiddenimports += get_all_modules_from_dir('mesonbuild/scripts')

# Python packagers want to be minimal and only copy the things
# that they can see being used. They are blind to many things.
hiddenimports += [
    # we run distutils as a subprocess via INTROSPECT_COMMAND.
    'distutils.archive_util',
    'distutils.cmd',
    'distutils.config',
    'distutils.core',
    'distutils.debug',
    'distutils.dep_util',
    'distutils.dir_util',
    'distutils.dist',
    'distutils.errors',
    'distutils.extension',
    'distutils.fancy_getopt',
    'distutils.file_util',
    'distutils.spawn',
    'distutils.util',
    'distutils.version',
    'distutils.command.build_ext',
    'distutils.command.build',
    'distutils.command.install',

    # needed for gtk's find_program() scripts
    'filecmp',
]