oetiker / rrdtool-1.x

RRDtool 1.x - Round Robin Database
http://www.rrdtool.org
GNU General Public License v2.0
988 stars 258 forks source link

Should prefer python3 over python2 #1221

Open diederikdehaas opened 1 year ago

diederikdehaas commented 1 year ago

Describe the bug Apparently I still have python2 installed on my (amd64) system and when running ./configure it selected that to build bindings for. I (ofc) also have python3 installed (and python3-dev), but it didn't select that. Given that python2 is EOL, I think it should use python3 if that's available.

To Reproduce Steps to reproduce the behavior:

  1. Have both python2 and python3 installed
  2. Clone this repo and install build dependencies
  3. cd into the directory containing the project (rrdtool-1.x)
  4. Run ./bootstrap and then ./configure
  5. See that it will use python2 instead of python3

Expected behavior If python3 is installed, it should use/prefer that over python2

Screenshots If applicable, add screenshots to help explain your problem.

Prep for Building Language Bindings
checking for perl... /usr/bin/perl
...
checking for a Python interpreter with version >= 2.3... python2
checking for python2... /usr/bin/python2
checking for python2 version... 2.7
checking for python2 platform... linux2
checking for GNU default python2 prefix... ${prefix}
checking for GNU default python2 exec_prefix... ${exec_prefix}
checking for python2 script directory (pythondir)... ${PYTHON_PREFIX}/lib/python2.7/site-packages
checking for python2 extension module directory (pyexecdir)... ${PYTHON_EXEC_PREFIX}/lib/python2.7/site-packages
checking for headers required to compile python extensions... not found
configure: WARNING: could not find Python headers
...
config.status: executing po-directories commands

Apply Configuration Information
checking that generated files are newer than configure... done
configure: creating ./config.status
...
ordering CD from https://tobi.oetiker.ch/wish .... just kidding ;-)

----------------------------------------------------------------
Config is DONE!

          With MMAP IO: yes
          With Locking: yes
       Build rrd_graph: yes
     Build rrd_restore: yes
       Static programs: no
          Perl Modules: perl-piped perl-shared
           Perl Binary: /usr/bin/perl
          Perl Version: 5.36.0
          Perl Options: PREFIX=/opt/rrdtool-1.8.0 INSTALL_BASE= LIB=/opt/rrdtool-1.8.0/lib/perl/5.36.0 INSTALLSITEMAN3DIR=${datarootdir}/man/man3
          Ruby Modules: ruby
           Ruby Binary: /usr/bin/ruby
          Ruby Options: sitedir=/opt/rrdtool-1.8.0/lib/ruby
    Build Lua Bindings: no
      Systemd unit dir: /lib/systemd/system
    Build Tcl Bindings: no
 Build Python Bindings: no
         Python Binary: /usr/bin/python2
        Python Version: 2.7
        Build examples: yes
       Build rrdcached: yes
          Build rrdcgi: yes
       Build librrd MT: yes
           Use gettext: yes
           With libDBI: no
         With librados: no
          With libwrap: yes
      With systemd dir: /lib/systemd/system

             Libraries: -lcairo -lglib-2.0 -lgobject-2.0 -lharfbuzz -lm -lpango-1.0 -lpangocairo-1.0 -lpng -lwrap -lxml2 

Type 'make' to compile the software and use 'make install' to 
install everything to: /opt/rrdtool-1.8.0.

Desktop (please complete the following information):

Additional context I started looking at a build issue for 32-bit systems/hosts (will report on that later) when I noticed this issue.
When I followed the steps to reproduce on a (clean armhf/32bit) system with only python3 (and python3-dev) installed, it did the right thing.

diederikdehaas commented 1 year ago

I started looking at a build issue for 32-bit systems/hosts (will report on that later)

It turned out that backporting the below referenced commits since 1.8.0 fixed that build issue, see https://salsa.debian.org/rrdtool-team/rrdtool/-/merge_requests/4 for details.

Specifically after "Fix BUILD_DATE in rrdtool help output" Salsa's CI (and thus the build i386 job) succeeded.
No idea why, but I'll take it ;-)

hramrach commented 6 months ago

Sounds like this might work to prefer python3

diff --git a/configure.ac b/configure.ac index be8b4d6e..140ad111 100644 --- a/configure.ac +++ b/configure.ac @@ -1018,7 +1018,7 @@ AC_ARG_ENABLE(python,AS_HELP_STRING([--disable-python],[do not build the python

if test "$enable_python" = "yes"; then dnl Check for python -AM_PATH_PYTHON(2.3,[],[enable_python=no]) +AM_PATH_PYTHON(3,[],[AM_PATH_PYTHON(2.3,[],[enable_python=no])]) AM_CHECK_PYTHON_HEADERS(,[enable_python=no;AC_MSG_WARN(could not find Python headers)]) fi