From: Manuel Traut <manut@debian.org>
Date: Fri, 15 May 2026 20:16:29 +0200
Subject: Install into PYTHONDIR instead of /usr/share/meshy

Signed-off-by: Manuel Traut <manut@debian.org>
---
 src/meson.build | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/meson.build b/src/meson.build
index 4296d9f..a7ce904 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -43,8 +43,38 @@ views_sources = [
   'views/map_view.py',
 ]
 
-install_data(meshy_sources, install_dir: pkgdatadir / 'meshy')
-install_data(views_sources, install_dir: pkgdatadir / 'meshy' / 'views')
+message('Looking for dependencies')
+python_bin = python.find_installation('python3')
+if not python_bin.found()
+    error('No valid python3 binary found')
+else
+    message('Found python3 binary')
+endif
+
+# from https://github.com/AsavarTzeth/pulseeffects/blob/master/meson.build
+# Support Debian non-standard python paths
+# Fallback to Meson python module if command fails
+message('Getting python install path')
+py3_purelib = ''
+r = run_command(
+  python_bin.full_path(),
+  '-c',
+  'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=""))',
+  check: false,
+)
+
+if r.returncode() != 0
+  py3_purelib = python_bin.get_path('purelib')
+  if not py3_purelib.endswith('site-packages')
+    error('Cannot find python install path')
+  endif
+  python_dir = py3_purelib
+else
+  python_dir = r.stdout().strip()
+endif
+
+install_data(meshy_sources, install_dir: python_dir / 'meshy')
+install_data(views_sources, install_dir: python_dir / 'meshy' / 'views')
 
 configure_file(
   input: 'meshy.in',
