Switch to using Pyinstaller. Closes
Cx_freeze has not been updated in a long time and does not
even work with Python > 3.5.
@@ -56,7 +56,7 @@ class PackageGenerator:
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 @@ class PackageGenerator:
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 @@ class PackageGenerator:
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()
