From f08f0aa3c2db0020d1a577579f1d75476c1dd93f Mon Sep 17 00:00:00 2001
From: James Browning <jamesb.fe80@gmail.com>
Date: Thu, 25 Apr 2024 06:45:31 -0700
Subject: [PATCH 3/3] Make `waf bin_test` work with --enable-pylib=none`

---
 wafhelpers/bin_test.py | 13 ++-----------
 wscript                |  3 +++
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/wafhelpers/bin_test.py b/wafhelpers/bin_test.py
index c6c8a112b..40a64dd90 100644
--- a/wafhelpers/bin_test.py
+++ b/wafhelpers/bin_test.py
@@ -89,17 +89,8 @@ def cmd_bin_test(ctx):
     """Run a suite of binary tests."""
     fails = 0
 
-    cmd = ctx.env['PYTHON'] + ['-c',
-        'from __future__ import print_function;'
-        'import ntp.util;'
-        'print(ntp.util.stdversion())']
-    p = waflib.Utils.subprocess.Popen(cmd, env={'PYTHONPATH': '%s/main/tests/pylib' %
-                                                 waflib.Context.out_dir},
-                         universal_newlines=True,
-                         stdin=waflib.Utils.subprocess.PIPE,
-                         stdout=waflib.Utils.subprocess.PIPE,
-                         stderr=waflib.Utils.subprocess.PIPE, cwd=waflib.Context.out_dir)
-    version = p.communicate()[0].rstrip()
+    with open(str(ctx.bldnode) + "/VERSION.bld") as fp:
+        version = fp.read().strip()
 
     if ctx.env['PYTHON_ARGPARSE']:
         cmd_map_python.update(cmd_map_python_argparse)
diff --git a/wscript b/wscript
index fbe404309..8de4c3071 100644
--- a/wscript
+++ b/wscript
@@ -1065,6 +1065,9 @@ def build(ctx):
         ctx.recurse("ntpd")
         return
 
+    with open(str(ctx.bldnode) + "/VERSION.bld", "w") as fp:
+        fp.write("ntpsec-" + ctx.env.NTPSEC_VERSION_EXTENDED)
+
     if ctx.cmd == "build":
         # It's a waf gotcha that if there are object files (including
         # .pyc and .pyo files) in a source directory, compilation to
-- 
2.44.0

