Install python packaging directly from meson
Hello! When building GLib using a CI service, where this CI service is protected to changes and only can run the build steps, installing extra dependencies could be a real challenge.
Since GLib 2.79, the python package packaging
is mandatory in case building the project with meson: e597b189
However, installing that package is really difficult for us due CI limitations. So, I would like to ask to meson be in charge of installing that package instead. Something like:
diff --git a/meson.build b/meson.build
index 7534542..180272d 100644
--- a/meson.build
+++ b/meson.build
@@ -2419,7 +2419,18 @@ endif
glib_conf.set('HAVE_PROC_SELF_CMDLINE', have_proc_self_cmdline)
+python = import('python')
+packaging_dep = python.find_installation('packaging', required: false)
+if not packaging_dep.found()
+ install_command = ['pip', 'install', 'packaging']
+ install_result = run_command(install_command, check: true, capture: true)
+ if install_result.returncode() != 0
+ error('Failed to install packaging library using pip')
+ endif
+endif
+
python = import('python').find_installation(modules: ['packaging'])
+
# used for '#!/usr/bin/env <name>'
python_name = 'python3'
First check if packaging
is installed already, then install via pip in case negative. Yes, bit fragile because does not use the asked version of packaging, but can be improved.
I could open a merge request in case the maintainers agree in accepting this change.
Edited by Uilian Ries