Skip to content

Commit

Permalink
packaging: make sure pyinstaller sees our distributed data files
Browse files Browse the repository at this point in the history
Running pyinstaller to create a bundle, and using the resulting
`pyinst-tmp/meson/meson setup ...` with the cmake module revealed that
no data files were being bundled, unlike what we did for setup.cfg. Fix
this oversight.

Fixes #10163
  • Loading branch information
eli-schwartz authored and jpakkane committed Apr 9, 2022
1 parent e5aa47d commit 7ceec99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packaging/hook-mesonbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import os
from glob import glob

from PyInstaller.utils.hooks import collect_data_files

datas = []
hiddenimports = []

def get_all_modules_from_dir(dirname):
Expand All @@ -18,6 +21,10 @@ def get_all_modules_from_dir(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')

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typing =
mypy
typing_extensions; python_version <"3.8"

# this must be synced with packaging/hook-mesonbuild.py
[options.package_data]
mesonbuild.scripts = cmd_or_ps.ps1
mesonbuild.cmake.data = *
Expand Down

0 comments on commit 7ceec99

Please sign in to comment.