[libpeas/meson.msvc: 8/19] meson: Improve Python detection on Windows




commit c882c281913d37e76ee9b839c5b4845de8094787
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Nov 15 14:26:17 2019 +0800

    meson: Improve Python detection on Windows
    
    Standard Windows binaries from www.python.org typically come as an MSI
    installer, which do not include pkg-config files for us, and it is often
    the case that people have multiple installations of Python on their
    systems, such as having both 32-bit and 64-bit installations of Python,
    so we need to go a bit harder to look for Python 2,x/3.x installations,
    by:
    
    -Allow people to explicitly input a full path to their Python 2.x/3.x
     interpreters, so that the right include/lib paths for the desired
     Python installation(s) can be discovered and utilized.
    
    -If no explicit path is specified, let Meson's Python module look for
     the installations for us instead.

 meson.build       | 18 ++++++++++++++++++
 meson_options.txt |  7 +++++++
 2 files changed, 25 insertions(+)
---
diff --git a/meson.build b/meson.build
index dfa8004d..56aa7c33 100644
--- a/meson.build
+++ b/meson.build
@@ -11,6 +11,7 @@ project(
 gnome = import('gnome')
 i18n = import('i18n')
 pkg = import('pkgconfig')
+pymod = import('python')
 
 # Versioning
 version = meson.project_version()
@@ -115,7 +116,24 @@ if not python3_dep.found()
   python3_dep = dependency('python3', version: python3_req, required: false)
 endif
 
+if host_machine.system() == 'windows' and not python3_dep.found()
+  python3 = pymod.find_installation(get_option('python3_path'),
+                                    required: false)
+  if python3.found()
+    python3_dep = python3.dependency(version: python3_req, required: false)
+  endif
+endif
+
+
 python2_dep = dependency('python2', version: python2_req, required: false)
+if host_machine.system() == 'windows' and not python2_dep.found()
+  python2 = pymod.find_installation(get_option('python2_path') != '' ? get_option('python2_path') : 
'python2',
+                                    required: false)
+  if python2.found()
+    python2_dep = python2.dependency(version: python2_req, required: false)
+  endif
+endif
+
 pygobject_dep = dependency('pygobject-3.0', version: pygobject_req, required: false)
 lua51_dep = dependency('lua51', version: lua_req, required: false)
 if not lua51_dep.found()
diff --git a/meson_options.txt b/meson_options.txt
index 18e17790..9c4a4bf5 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,6 +9,13 @@ option('python3',
        type: 'boolean', value: true,
        description: 'Enable Python 3 support (requires pygobject)')
 
+option('python2_path',
+       type: 'string', value: '',
+       description: 'Path to Python 2.x interpreter (Windows only)')
+option('python3_path',
+       type: 'string', value: '',
+       description: 'Path to Python 3.x interpreter (Windows only)')
+
 option('introspection',
        type: 'boolean', value: true,
        description: 'Generate introspection data (requires gobject-introspection)')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]