ntpclients not using Python3 after install

ntpsec will not configure cleanly on my system (Debian Buster) with /usr/bin/python being 2.7.16. ./waf configure results in:

Checking for program 'python'                                   : /usr/bin/python
Checking for python version >= 2.6.0                            : 2.7.16
python-config                                                   : not found
Checking for library python2.7 in LIBDIR                        : not found
Checking for library python2.7 in python_LIBPL                  : yes
Checking for header Python.h                                    : Distutils not installed? Broken python installation? Get python-config now!
The configuration failed

It does, however, configure and build cleanly through the use of Python3 - which I'd prefer to use anyway, given the deprecated status of Python21:

python3 ./waf configure
...
Checking for program 'python'                                   : /usr/bin/python3
Checking for python version >= 2.6.0                            : 3.7.3
python-config                                                   : /usr/bin/python3-config
Asking python-config for pyext '--cflags --libs --ldflags' flags : yes
Testing pyext configuration                                      : yes
Checking for python module 'curses'                              : ok
Checking for python module 'argparse'                            : 1.1
Checking for python module 'gps' (ver >= num(3, 18))             : not found
WARNING: ntploggps will not be built/installed since python gps module >= 3.18 was not found
	PYTHONDIR                     :  /usr/local/lib/python3/dist-packages
	PYTHONARCHDIR                 :  /usr/local/lib/python3/dist-packages
'configure' finished successfully (20.821s)

(The gps module for Python3 is a separate issue.)

However, the ntpclients are apparently coded to still use the system default python:

$ head -n1 /usr/local/bin/ntpq
#!/usr/bin/env python

When run by default, this results in an error:

$ ntpq
ntpq: can't find Python NTP library -- check PYTHONPATH.
No module named ntp.control

... as the Python NTP libraries were installed for Python3, but the client is running under Python2.

I can improve upon this by manually running this as python3 /usr/local/bin/ntpq - but then I'm still left with other issues to work through as /usr/local/lib/python3/dist-packages is not on Debian's PYTHONPATH by default 2.

For the purposes of this ticket: Can the ntpclients be updated to use /usr/bin/env python3, since Python2 has been EOL since 2020-01-01 now1? Or can there at least be a waf configuration to drive this? Or how can I better handle this without manually needing to edit (and maintain) each of these files?

This all started as the distribution-provided ntpsec does not have the gpsd driver included.

If there is any way that I should be doing any of this differently, please advise as well. Thanks!

  1. https://www.python.org/doc/sunset-python-2/ 2

  2. https://bugs.python.org/issue10196