diff options
Diffstat (limited to 'packaging')
-rwxr-xr-x | packaging/createmsi.py | 47 | ||||
-rwxr-xr-x | packaging/createpkg.py | 5 | ||||
-rw-r--r-- | packaging/hook-mesonbuild.py | 49 |
3 files changed, 51 insertions, 50 deletions
diff --git a/packaging/createmsi.py b/packaging/createmsi.py index 653caa5..fe49b7b 100755 --- a/packaging/createmsi.py +++ b/packaging/createmsi.py @@ -39,49 +39,6 @@ def gen_guid(): ''' return str(uuid.uuid4()).upper() -def get_all_modules_from_dir(dirname): - ''' - Get all modules required for Meson build MSI package - 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 - -def get_more_modules(): - ''' - Getter for missing Modules. - Python packagers want to be minimal and only copy the things - that they can see that being used. They are blind to many things. - ''' - return ['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', - 'filecmp', - ] - -def get_modules(): - modules = get_all_modules_from_dir('mesonbuild/modules') - modules += get_all_modules_from_dir('mesonbuild/scripts') - modules += get_more_modules() - return modules - class Node: ''' Node to hold path and directory values @@ -166,7 +123,6 @@ class PackageGenerator: if os.path.exists(sdir): shutil.rmtree(sdir) main_stage, ninja_stage = self.staging_dirs - modules = get_modules() pyinstaller = shutil.which('pyinstaller') if not pyinstaller: @@ -178,10 +134,9 @@ class PackageGenerator: shutil.rmtree(pyinstaller_tmpdir) pyinst_cmd = [pyinstaller, '--clean', + '--additional-hooks-dir=packaging', '--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) diff --git a/packaging/createpkg.py b/packaging/createpkg.py index 533b3b9..70da656 100755 --- a/packaging/createpkg.py +++ b/packaging/createpkg.py @@ -22,8 +22,6 @@ import xml.etree.ElementTree as ET sys.path.append(os.getcwd()) from mesonbuild import coredata -from createmsi import get_modules - class PkgGenerator: def __init__(self): @@ -46,10 +44,9 @@ class PkgGenerator: pyinstaller_bin = '/Users/jpakkane/Library/Python/3.8/bin/pyinstaller' pyinst_cmd = [pyinstaller_bin, '--clean', + '--additional-hooks-dir=packaging', '--distpath', self.pkg_dir] - for m in get_modules(): - pyinst_cmd += ['--hidden-import', m] pyinst_cmd += ['meson.py'] subprocess.check_call(pyinst_cmd) tmpdir = os.path.join(self.pkg_dir, 'meson') diff --git a/packaging/hook-mesonbuild.py b/packaging/hook-mesonbuild.py new file mode 100644 index 0000000..b5f09ef --- /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', +] |