[meld] Update meson build to byte-compile Python source by default
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Update meson build to byte-compile Python source by default
- Date: Sat, 25 Apr 2020 01:17:22 +0000 (UTC)
commit 3b682e168be3f3becd8bc5d1745618d151fac83c
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Apr 25 11:12:09 2020 +1000
Update meson build to byte-compile Python source by default
This includes the option to disable byte compilation for the benefit of
distributions.
meson.build | 6 +++++-
meson_options.txt | 6 ++++++
meson_post_install.py | 8 ++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 378c9ea9..90612a0a 100644
--- a/meson.build
+++ b/meson.build
@@ -59,4 +59,8 @@ subdir('po')
install_data('bin/meld', install_dir: bindir)
-meson.add_install_script('meson_post_install.py')
+if get_option('byte-compile')
+ meson.add_install_script('meson_post_install.py', python3.get_install_dir())
+else
+ meson.add_install_script('meson_post_install.py')
+endif
diff --git a/meson_options.txt b/meson_options.txt
index fa5966ae..9c545a9c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,3 +4,9 @@ option(
value: '',
description: 'Build with specified application ID',
)
+option(
+ 'byte-compile',
+ type: 'boolean',
+ value: true,
+ description: 'Byte-compile installed Python source files',
+)
diff --git a/meson_post_install.py b/meson_post_install.py
index 682633a3..79bc1ac5 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
+import sys
+from compileall import compile_dir
from os import environ, path
from subprocess import call
@@ -12,3 +14,9 @@ if not environ.get('DESTDIR', ''):
call(["glib-compile-schemas", path.join(DATA_DIR, 'glib-2.0', 'schemas')])
print("Updating desktop database")
call(["update-desktop-database", path.join(DATA_DIR, 'applications')])
+
+# Byte-compilation is enabled by passing the site-packages path to this script
+if len(sys.argv) > 1:
+ print('Byte-compiling Python module...')
+ python_source_install_path = sys.argv[1]
+ compile_dir(path.join(python_source_install_path, 'meld'), optimize=1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]