]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3731] Compute PKGPYTHONDIR in a single place
authorAndrei Pavel <andrei@isc.org>
Thu, 13 Mar 2025 05:54:06 +0000 (07:54 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 13 Mar 2025 17:03:38 +0000 (18:03 +0100)
meson.build
src/bin/shell/meson.build

index edd18a492eb3ce5701cfdb0ce67a6b21569f274b..a3371d42f2619b981babd93487134f12263866ab 100644 (file)
@@ -8,6 +8,7 @@ PROJECT_VERSION = meson.project_version()
 #### Imports
 
 fs = import('fs')
+python_module = import('python')
 
 #### Variables
 
@@ -237,6 +238,23 @@ else
     error('Dependency not found: neither Botan nor OpenSSL.')
 endif
 
+# Kea shell
+PKGPYTHONDIR = 'unknown'
+py_installation = python_module.find_installation('python3', required: false)
+if py_installation.found()
+    PKGPYTHONDIR = py_installation.get_install_dir(pure: true) / 'kea'
+else
+    result = run_command(
+        PYTHON,
+        '-c',
+        'import sysconfig; print(sysconfig.get_paths()[\'purelib\'])',
+        check: false,
+    )
+    if result.returncode() == 0
+        PKGPYTHONDIR = result.stdout().strip() / 'kea'
+    endif
+endif
+
 if TESTS_OPT.enabled()
     conf_data.set('ENABLE_DEBUG', true)
     conf_data.set('ENABLE_LOGGER_CHECKS', true)
@@ -473,17 +491,7 @@ report_conf_data.set('LD_ID', cpp.get_linker_id())
 report_conf_data.set('LD_ARGS', ' '.join(link_args))
 report_conf_data.set('PYTHON_PATH', PYTHON.full_path())
 report_conf_data.set('PYTHON_VERSION', PYTHON.version())
-result = run_command(
-    PYTHON,
-    '-c',
-    'import sysconfig; print(sysconfig.get_paths()[\'purelib\'])',
-    check: false,
-)
-if result.returncode() == 0
-    report_conf_data.set('PKGPYTHONDIR', result.stdout().strip() + '/kea')
-else
-    report_conf_data.set('PKGPYTHONDIR', 'unknown')
-endif
+report_conf_data.set('PKGPYTHONDIR', PKGPYTHONDIR)
 result = cpp.run(
     fs.read('compiler-checks/get-boost-version.cc'),
     dependencies: [boost_dep],
index 31f2ed44c5aaa1cf32a3abeb86ae9f944a7c2d54..3ce85bcd4e88565bfb7cfde11e58d56cccf30183 100644 (file)
@@ -2,12 +2,7 @@ kea_shell_conf_data = configuration_data()
 kea_shell_conf_data.set('PYTHON', PYTHON.full_path())
 kea_shell_conf_data.set('PACKAGE_VERSION', PROJECT_VERSION)
 kea_shell_conf_data.set('EXTENDED_VERSION', PROJECT_VERSION + ' (tarball)')
-
-python = import('python')
-py_installation = python.find_installation('python3', required: true)
-python_install_dir = py_installation.get_install_dir(pure: true)
-pkgpythondir = python_install_dir / 'kea'
-kea_shell_conf_data.set('PKGPYTHONDIR', pkgpythondir)
+kea_shell_conf_data.set('PKGPYTHONDIR', PKGPYTHONDIR)
 
 configure_file(
     input: 'kea-shell.in',
@@ -21,13 +16,13 @@ configure_file(
     output: 'kea_conn.py',
     copy: true,
     install: true,
-    install_dir: pkgpythondir,
+    install_dir: PKGPYTHONDIR,
 )
 configure_file(
     input: 'kea_connector3.py',
     output: 'kea_connector3.py',
     copy: true,
     install: true,
-    install_dir: pkgpythondir,
+    install_dir: PKGPYTHONDIR,
 )
 subdir('tests')