diff options
| author | Eli Schwartz <eschwartz@archlinux.org> | 2022-03-27 00:56:26 -0400 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-03-30 02:06:52 +0300 |
| commit | 258cd5d5836a6660f1122cec274f0a947c1d0459 (patch) | |
| tree | 72f1ecb04c9c3540aa03ba23ef512a2a1c00ea32 /packaging/hook-mesonbuild.py | |
| parent | ff8a9c9efb9937e7d7776bba8b85930ed44192fa (diff) | |
| download | meson-258cd5d5836a6660f1122cec274f0a947c1d0459.tar.gz | |
packaging: rework how pyinstaller gets its instructions
Make use of pyinstaller hooks by creating a hook that updates how the
`mesonbuild` import functions.
This is more or less the same as passing a bajillion arguments to
pyinstaller's CLI, but allows the logic to be self-contained (and
reusable). It becomes more obvious what parts of the process pertain to
pyinstaller, and which parts pertain to MSI/pkg creation.
Diffstat (limited to 'packaging/hook-mesonbuild.py')
| -rw-r--r-- | packaging/hook-mesonbuild.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py new file mode 100644 index 000000000..b5f09effe --- /dev/null +++ b/packaging/hook-mesonbuild.py @@ -0,0 +1,49 @@ +#!hint/python3 + +""" +PyInstaller hook to make mesonbuild include everything it needs to. +""" + +import os +from glob import glob + +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 + +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', +] |
