Repository: mesonbuild/meson

Issue:
Unhandled python exception with 0.62 on windows (0.61 ok)
**Describe the bug**
When running meson 0.62 on win32 and a project using `dependency()` (ex glib):

Unhandled python exception
ModuleNotFoundError: No module named 'mesonbuild.dependencies.data'

```
Traceback (most recent call last):
  File "mesonbuild\mesonmain.py", line 151, in run
  File "mesonbuild\msetup.py", line 301, in run
  File "mesonbuild\msetup.py", line 185, in generate
  File "mesonbuild\msetup.py", line 229, in _generate
  File "mesonbuild\interpreter\interpreter.py", line 2698, in run
  File "mesonbuild\interpreterbase\interpreterbase.py", line 149, in run
  File "mesonbuild\interpreterbase\interpreterbase.py", line 174, in evaluate_codeblock
  File "mesonbuild\interpreterbase\interpreterbase.py", line 167, in evaluate_codeblock
  File "mesonbuild\interpreterbase\interpreterbase.py", line 182, in evaluate_statement
  File "mesonbuild\interpreterbase\interpreterbase.py", line 567, in assignment
  File "mesonbuild\interpreterbase\interpreterbase.py", line 180, in evaluate_statement
  File "mesonbuild\interpreterbase\interpreterbase.py", line 455, in function_call
  File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped
  File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped
  File "mesonbuild\interpreterbase\decorators.py", line 768, in wrapped
  [Previous line repeated 5 more times]
  File "mesonbuild\interpreterbase\decorators.py", line 109, in wrapped
  File "mesonbuild\interpreterbase\decorators.py", line 127, in wrapped
  File "mesonbuild\interpreterbase\decorators.py", line 277, in wrapper
  File "mesonbuild\interpreter\interpreter.py", line 1620, in func_dependency
  File "mesonbuild\interpreter\dependencyfallbacks.py", line 352, in lookup
  File "mesonbuild\interpreter\dependencyfallbacks.py", line 93, in _do_dependency
  File "mesonbuild\dependencies\detect.py", line 112, in find_external_dependency
  File "mesonbuild\dependencies\cmake.py", line 135, in __init__
  File "mesonbuild\dependencies\cmake.py", line 183, in _get_cmake_info
  File "mesonbuild\dependencies\cmake.py", line 614, in _call_cmake
  File "mesonbuild\dependencies\cmake.py", line 585, in _setup_cmake_dir
  File "importlib\resources.py", line 103, in read_text
  File "importlib\resources.py", line 82, in open_text
  File "importlib\resources.py", line 43, in open_binary
  File "importlib\_common.py", line 66, in get_package
  File "importlib\_common.py", line 57, in resolve
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'mesonbuild.dependencies.data'
```

**To Reproduce**
project('foo')
pcre = dependency('libpcre')

**system parameters**
meson 0.62 (MSI) on windev VM (https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/)
works as expected on 0.61


Discussion:
Have you wiped your builddir after upgrading to 0.62?
Forget that, it's probably https://github.com/mesonbuild/meson/commit/140097faf0eddcc7819a3353eb7c21b82a7df1e0. 

CC @eli-schwartz 
That seems quite likely, but what I don't understand is: this is stdlib functionality and the reason it is supposed to be so good (as opposed to pkg_resources) is specifically because it works everywhere.

I am very curious to know what the MSI is doing differently to set up its installation environment, but I don't have the right system to investigate.

Does that directory exist at all inside the meson module as packaged in the MSI?
@eli-schwartz if you have linux+kvm, you may want to install a free trial windev vm. I have a script that can help (https://github.com/elmarco/virt-install-windev), but it is partially broken.

Resolving patch:
diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py
--- a/packaging/hook-mesonbuild.py
+++ b/packaging/hook-mesonbuild.py
@@ -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):
@@ -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')
 


Test patch: