[libgit2-glib] Revert "Use python3"



commit a97a65fd9e3e7263baab1c325e022e6e550a8b1d
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Jun 17 12:38:37 2021 +0200

    Revert "Use python3"
    
    This reverts commit 8a1da431dcbf4eda612b5189201f502fbf122726.
    
    The commit removed some use of the `python` module to be able to
    explicitly compile with `python3` in the post install script
    because although meson was using `python` module properly the post
    install script was calling `python` binary that might not point to
    `python3` binary.
    
    The commit has been reverted and proper solution has been applied by
    passing the `python3` installation path used by meson to the post
    install script.
    
    The `python3-gobject-devel` has also been added as a requirement for
    the CI step.

 .gitlab-ci.yml           |  2 +-
 libgit2-glib/meson.build |  5 +++--
 meson.build              | 13 +++++++++----
 meson_python_compile.py  |  8 +++++---
 meson_vapi_link.py       |  7 ++-----
 5 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9353884..33bdea6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: fedora:34
 stages:
   - build
 before_script:
-  - dnf install -y gcc meson ninja-build gettext gi-docgen glib2-devel libgit2-devel 
gobject-introspection-devel vala libssh2-devel
+  - dnf install -y gcc meson ninja-build gettext gi-docgen glib2-devel libgit2-devel 
gobject-introspection-devel python3-gobject-devel vala libssh2-devel
 build-libgit2-glib:
   stage: build
   script:
diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build
index 3676ea7..27fdb4c 100644
--- a/libgit2-glib/meson.build
+++ b/libgit2-glib/meson.build
@@ -237,9 +237,10 @@ libgit2_glib_dep = declare_dependency(
 )
 
 if enable_python
-  install_data(
+  python.install_sources(
     'Ggit.py',
-    install_dir: python.sysconfig_path('purelib') / 'gi/overrides',
+    pure: false,
+    subdir: 'gi/overrides',
   )
 endif
 
diff --git a/meson.build b/meson.build
index fbfa8e5..0fcd55d 100644
--- a/meson.build
+++ b/meson.build
@@ -38,8 +38,8 @@ libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
 darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, revision)]
 
 libgit2_glib_prefix = get_option('prefix')
-libgit2_glib_libdir = libgit2_glib_prefix / get_option('libdir')
-libgit2_glib_datadir = libgit2_glib_prefix / get_option('datadir')
+libgit2_glib_libdir = get_option('libdir')
+libgit2_glib_datadir = get_option('datadir')
 
 libgit2_glib_pkgincludedir = get_option('includedir') / libgit2_glib_api_name / meson.project_name()
 
@@ -158,9 +158,14 @@ endif
 # Check for python
 enable_python = get_option('python')
 if enable_python
-  python = import('python3')
+  python = import('python').find_installation('python3')
 
-  meson.add_install_script('meson_python_compile.py', libgit2_glib_libdir)
+  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_python_compile.py', libgit2_glib_libdir, python.path())
 endif
 
 subdir('libgit2-glib')
diff --git a/meson_python_compile.py b/meson_python_compile.py
old mode 100755
new mode 100644
index 24a74d8..9398fbd
--- a/meson_python_compile.py
+++ b/meson_python_compile.py
@@ -5,10 +5,12 @@ import subprocess
 import sys
 
 if not os.environ.get('DESTDIR'):
-  libdir = sys.argv[1]
+  prefix = os.environ['MESON_INSTALL_PREFIX']
+
+  libdir = os.path.join(prefix, sys.argv[1])
 
   print('Byte-compiling python modules...')
-  subprocess.check_call(['python3', '-m', 'compileall', '-f', '-q', libdir])
+  subprocess.call([sys.argv[2], '-m', 'compileall', '-f', '-q', libdir])
 
   print('Byte-compiling python modules (optimized versions) ...')
-  subprocess.check_call(['python3', '-O', '-m', 'compileall', '-f', '-q', libdir])
+  subprocess.call([sys.argv[2], '-O', '-m', 'compileall', '-f', '-q', libdir])
diff --git a/meson_vapi_link.py b/meson_vapi_link.py
index db1e4e8..9eb3f2c 100755
--- a/meson_vapi_link.py
+++ b/meson_vapi_link.py
@@ -4,12 +4,9 @@ import os
 import shutil
 import sys
 
-datadir = sys.argv[1]
+prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] if os.environ.get('DESTDIR') else 
os.environ['MESON_INSTALL_PREFIX']
 
-destdir = os.environ.get('DESTDIR')
-if destdir:
-    datadir = os.path.splitdrive(datadir)[1].lstrip(os.path.sep)
-    datadir = os.path.join(destdir, datadir)
+datadir = os.path.join(prefix, sys.argv[1])
 
 vapidir = os.path.join(datadir, 'vala', 'vapi')
 os.chdir(vapidir)


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