[libgit2-glib] meson: Add python support
- From: Iñigo Martínez <inigomartinez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] meson: Add python support
- Date: Mon, 22 Jan 2018 09:33:40 +0000 (UTC)
commit 5f2a419fe1e3d53aeb96f72de9cc7713322e5920
Author: Iñigo Martínez <inigomartinez gmail com>
Date: Fri Jan 19 22:07:07 2018 +0100
meson: Add python support
autotools features optional python support, which makes some checks
regarding python and pygobject versions and compiles the installed
python files.
This patch adds the equivalent python support in meson.
https://bugzilla.gnome.org/show_bug.cgi?id=792699
libgit2-glib/meson.build | 4 ++++
meson.build | 13 +++++++++++++
meson_options.txt | 1 +
meson_post_install.py | 14 ++++++++++++++
4 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build
index c0f68de..efd930c 100644
--- a/libgit2-glib/meson.build
+++ b/libgit2-glib/meson.build
@@ -229,6 +229,10 @@ libgit2_glib_dep = declare_dependency(link_with: libgit2_glib,
# Everything that uses libgit2-glib needs this built to compile
sources: enum_types[1])
+if enable_python
+ install_data('Ggit.py', install_dir: join_paths(python.sysconfig_path('purelib'), 'gi', 'overrides'))
+endif
+
if enable_gir
libgit2_glib_gir = gnome.generate_gir(libgit2_glib,
sources: headers + sources,
diff --git a/meson.build b/meson.build
index 05c127f..c93552d 100644
--- a/meson.build
+++ b/meson.build
@@ -148,6 +148,19 @@ if enable_ssh
assert(cc.compiles(libgit2_ssh_src, name: 'libgit2 supports SSH'), 'libgit2 ssh support was requested, but
not found. Use -Dssh=false to build without it.')
endif
+# Check for python
+enable_python = get_option('python')
+if enable_python
+ python = import('python3')
+
+ python_req = '3.2.3'
+
+ dependency('pygobject-3.0', version: '>= 3.0.0')
+ assert(python.language_version().version_compare('>= ' + python_req), 'python support was requested, but
version >= ' + python_req + ' not found.')
+
+ meson.add_install_script('meson_post_install.py', libgit2_glib_libdir)
+endif
+
gnome = import('gnome')
pkg = import('pkgconfig')
diff --git a/meson_options.txt b/meson_options.txt
index 896c998..90b3188 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,5 @@
option('gtk_doc', type: 'boolean', value: false, description: 'Enable generating the API reference (depends
on GTK-Doc)')
option('introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection')
+option('python', type: 'boolean', value: true, description: 'Build with python support')
option('ssh', type: 'boolean', value: true, description: 'Build with libgit2 ssh support')
option('vapi', type: 'boolean', value: true, description: 'Build Vala bindings')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..8aff82c
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+ libdir = sys.argv[1]
+
+ print('Byte-compiling python modules...')
+ subprocess.call(['python', '-m', 'compileall', '-f', '-q', libdir])
+
+ print('Byte-compiling python modules (optimized versions) ...')
+ subprocess.call(['python', '-O', '-m', 'compileall', '-f', '-q', libdir])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]