From f838b2ab03af0285043d980feba9d52d96d66164 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Fri, 15 May 2020 08:34:40 -0400 Subject: [PATCH] Build: Only generate python bytecode during builds with no temporary install folder. Package managers should handle this otherwise. This eliminates a lot of warnings during the packaging portion of the deb build. --- install-scripts/meson.build | 16 ++++++++++++++++ install-scripts/meson_compile_python.py | 10 ++++++++++ meson.build | 1 + src/meson.build | 2 -- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 install-scripts/meson.build create mode 100644 install-scripts/meson_compile_python.py diff --git a/install-scripts/meson.build b/install-scripts/meson.build new file mode 100644 index 0000000..667d669 --- /dev/null +++ b/install-scripts/meson.build @@ -0,0 +1,16 @@ +# These scripts run as post-installation scripts. + +# They're designed to do nothing if DESTDIR is set, which happens +# during debian builds for instance - there's a fake install target +# so running these would be pointless. + +# When using deb packaging, these aren't needed, as these operations +# are run automatically by the package manager. + +# They're really only necessary in straight builds where 'ninja install' +# will be run directly, to install the program onto the system. + + +# Generate python bytecode +meson.add_install_script('meson_compile_python.py') + diff --git a/install-scripts/meson_compile_python.py b/install-scripts/meson_compile_python.py new file mode 100644 index 0000000..9ec0f4d --- /dev/null +++ b/install-scripts/meson_compile_python.py @@ -0,0 +1,10 @@ +#!/usr/bin/python3 + +import os +import subprocess + +pythondir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'cinnamon-screensaver') + +if not os.environ.get('DESTDIR'): + print('Generating python bytecode...') + subprocess.call(['sh', '-c', 'python3 -m compileall "%s"' % pythondir]) diff --git a/meson.build b/meson.build index c508770..d7dcd31 100644 --- a/meson.build +++ b/meson.build @@ -123,6 +123,7 @@ conf_h = configure_file( inc = include_directories('.') +subdir('install-scripts') subdir('libcscreensaver') subdir('data') subdir('src') diff --git a/src/meson.build b/src/meson.build index 7e0978e..f04fda0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -64,5 +64,3 @@ foreach script : app_scripts meson.add_install_script('sh', '-c', 'ln -sf "@0@" "$DESTDIR/@1@"'.format(join_paths(pkgdatadir, script[0]), join_paths(bindir, script[1]))) endforeach - -meson.add_install_script('sh', '-c', 'python3 -m compileall "$DESTDIR/@0@"'.format(pkgdatadir) )