Repository: mesonbuild/meson

Issue:
running meson fails on latest release 0.51.0
i installed meson 0.51.0 64 using the msi installer and when running "meson" as a test i produces this stack trace:
Traceback (most recent call last):

```
  File "C:\python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
  File "C:\python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
  File "meson.py", line 22, in <module>
  File "C:\python\lib\pathlib.py", line 1109, in resolve
  File "C:\python\lib\pathlib.py", line 186, in resolve
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'meson'
```

i rolled back to version 0.50.1 which worked correctly


Discussion:

Resolving patch:
diff --git a/msi/createmsi.py b/msi/createmsi.py
--- a/msi/createmsi.py
+++ b/msi/createmsi.py
@@ -56,7 +56,7 @@ def __init__(self):
             redist_glob = 'C:\\Program Files\\Microsoft Visual Studio\\2017\\Community\\VC\\Redist\\MSVC\\*\\MergeModules\\Microsoft_VC141_CRT_x86.msm'
         trials = glob(redist_glob)
         if len(trials) != 1:
-            sys.exit('There are more than one potential redist dirs.')
+            sys.exit('Could not find unique MSM setup.')
         self.redist_path = trials[0]
         self.component_num = 0
         self.feature_properties = {
@@ -114,20 +114,24 @@ def build_dist(self):
         modules = self.get_all_modules_from_dir('mesonbuild/modules')
         modules += self.get_all_modules_from_dir('mesonbuild/scripts')
         modules += self.get_more_modules()
-        modulestr = ','.join(modules)
-        python = shutil.which('python')
-        cxfreeze = os.path.join(os.path.dirname(python), "Scripts", "cxfreeze")
-        if not os.path.isfile(cxfreeze):
-            print("ERROR: This script requires cx_freeze module")
+
+        pyinstaller = shutil.which('pyinstaller')
+        if not pyinstaller:
+            print("ERROR: This script requires pyinstaller.")
             sys.exit(1)
 
-        subprocess.check_call([python,
-                               cxfreeze,
-                               '--target-dir',
-                               main_stage,
-                               '--include-modules',
-                               modulestr,
-                               'meson.py'])
+        pyinstaller_tmpdir = 'pyinst-tmp'
+        if os.path.exists(pyinstaller_tmpdir):
+            shutil.rmtree(pyinstaller_tmpdir)
+        pyinst_cmd = [pyinstaller,
+                      '--clean',
+                      '--distpath',
+                      pyinstaller_tmpdir]
+        for m in modules:
+            pyinst_cmd += ['--hidden-import', m]
+        pyinst_cmd += ['meson.py']
+        subprocess.check_call(pyinst_cmd)
+        shutil.move(pyinstaller_tmpdir + '/meson', main_stage)
         if not os.path.exists(os.path.join(main_stage, 'meson.exe')):
             sys.exit('Meson exe missing from staging dir.')
         os.mkdir(ninja_stage)
@@ -288,7 +292,7 @@ def build_package(self):
 if __name__ == '__main__':
     if not os.path.exists('meson.py'):
         sys.exit(print('Run me in the top level source dir.'))
-    subprocess.check_call(['pip', 'install', '--upgrade', 'cx_freeze'])
+    subprocess.check_call(['pip', 'install', '--upgrade', 'pyinstaller'])
 
     p = PackageGenerator()
     p.build_dist()


Test patch: