From ea20fb536aae58f008a282feaa12868e72ce78d9 Mon Sep 17 00:00:00 2001 From: Thibaut Paumard Date: Fri, 25 Oct 2019 14:33:14 +0200 Subject: [PATCH] plugins/python: support Python 3.8 With Python 3.8, modules are no longer link with libpython by default. Therefore codes that are meant for embedding Python must pass --embed to python-configure in order to get the complete set of flags to do so. --- configure | 21 +++++++++++++-------- m4/python.m4 | 24 +++++++++++++++--------- plugins/python/configure | 13 +++++++++---- plugins/python/configure.ac | 2 +- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/configure b/configure index 64b56846..235eeaa0 100755 --- a/configure +++ b/configure @@ -16087,6 +16087,11 @@ $as_echo "no" >&6; } fi +if test "x" = "xyes" && $PYTHON_CONFIGURE --embed; then : + PYTHON_EMBED_FLAG="--embed" +else + PYTHON_EMBED_FLAG="" +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python includes" >&5 $as_echo_n "checking for Python includes... " >&6; } @@ -16094,7 +16099,7 @@ if ${pc_cv_python_includes+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&5` + pc_cv_python_includes=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --includes 2>&5` else pc_cv_python_includes="-I$includedir/$_PYTHON_BASENAME" fi @@ -16112,7 +16117,7 @@ if ${pc_cv_python_prefix+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&5` + pc_cv_python_prefix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --prefix 2>&5` else ac_ext=py ac_compile='chmod +x conftest.$ac_ext >&5' @@ -16158,7 +16163,7 @@ if ${pc_cv_python_exec_prefix+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>&5` + pc_cv_python_exec_prefix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --exec-prefix 2>&5` else ac_ext=py ac_compile='chmod +x conftest.$ac_ext >&5' @@ -16210,7 +16215,7 @@ if ${pc_cv_python_includes+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&5` + pc_cv_python_includes=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --includes 2>&5` else pc_cv_python_includes="-I$includedir/$_PYTHON_BASENAME" fi @@ -16226,7 +16231,7 @@ if ${pc_cv_python_cflags+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&5` + pc_cv_python_cflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --cflags 2>&5` else pc_cv_python_cflags= fi @@ -16242,7 +16247,7 @@ if ${pc_cv_python_ldflags+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&5` + pc_cv_python_ldflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --ldflags 2>&5` else pc_cv_python_ldflags= fi @@ -16258,7 +16263,7 @@ if ${pc_cv_python_libs+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&5` + pc_cv_python_libs=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --libs 2>&5` else pc_cv_python_libs="-l$_PYTHON_BASENAME" fi @@ -16424,7 +16429,7 @@ if ${pc_cv_python_extension_suffix+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&5` + pc_cv_python_extension_suffix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --extension-suffix 2>&5` else pc_cv_python_extension_suffix= fi diff --git a/m4/python.m4 b/m4/python.m4 index 58aef433..345a2aaa 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -1,4 +1,5 @@ # Copyright 2012, 2013, 2014 Brandon Invergo +# Copyright 2019 Thibaut Paumard # # This file is part of pyconfigure. This program is free # software; you can redistribute it and/or modify it under the @@ -43,6 +44,7 @@ # # 4. Looking for specific libs & functionality +# 2019-10-25 Thibaut Paumard add support for --embed in Python >= 3.8 ## ----------------------- ## ## 1. Language selection. ## @@ -160,9 +162,10 @@ m4_ifval([$1], ])# PC_PROG_PYTHON -# PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR) +# PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR,EMBED) # ---------------------------------------------- # Find the python-config program +# Set EMBED to 'yes' if embedding Python. AC_DEFUN([PC_PYTHON_PROG_PYTHON_CONFIG], [AC_REQUIRE([PC_PROG_PYTHON])[]dnl AC_ARG_VAR([PYTHON_CONFIG], [the Python-config program]) @@ -172,6 +175,9 @@ m4_define([_PYTHON_BASENAME], [`basename $PYTHON`]) m4_ifval([$1], [AC_PATH_PROGS(PYTHON_CONFIG, [$1 _PYTHON_BASENAME-config])], [AC_PATH_PROG(PYTHON_CONFIG, _PYTHON_BASENAME-config)]) +AS_IF([test "x$2" = "xyes" && $PYTHON_CONFIGURE --embed], + [PYTHON_EMBED_FLAG="--embed"], + [PYTHON_EMBED_FLAG=""]) ]) # PC_PYTHON_PROG_PYTHON_CONFIG @@ -252,7 +258,7 @@ AC_DEFUN([PC_PYTHON_CHECK_PREFIX], dnl Try to get it with python-config otherwise do it from within Python AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_prefix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --prefix 2>&AS_MESSAGE_LOG_FD` else AC_LANG_PUSH(Python)[]dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl @@ -277,7 +283,7 @@ AC_DEFUN([PC_PYTHON_CHECK_EXEC_PREFIX], dnl Try to get it with python-config otherwise do it from within Python AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_exec_prefix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --exec-prefix 2>&AS_MESSAGE_LOG_FD` else AC_LANG_PUSH(Python)[]dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl @@ -305,7 +311,7 @@ AC_DEFUN([PC_PYTHON_CHECK_INCLUDES], dnl Try to find the headers location with python-config otherwise guess AC_CACHE_CHECK([for Python includes], [pc_cv_python_includes], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_includes=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --includes 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)" @@ -334,7 +340,7 @@ AC_DEFUN([PC_PYTHON_CHECK_LIBS], dnl Try to find the lib flags with python-config otherwise guess AC_CACHE_CHECK([for Python libs], [pc_cv_python_libs], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_libs=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --libs 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)" fi @@ -368,7 +374,7 @@ AC_DEFUN([PC_PYTHON_CHECK_CFLAGS], dnl Try to find the CFLAGS with python-config otherwise give up AC_CACHE_CHECK([for Python CFLAGS], [pc_cv_python_cflags], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_cflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --cflags 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_cflags= fi @@ -384,7 +390,7 @@ AC_DEFUN([PC_PYTHON_CHECK_LDFLAGS], dnl Try to find the LDFLAGS with python-config otherwise give up AC_CACHE_CHECK([for Python LDFLAGS], [pc_cv_python_ldflags], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_ldflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --ldflags 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_ldflags= fi @@ -400,7 +406,7 @@ AC_DEFUN([PC_PYTHON_CHECK_EXTENSION_SUFFIX], dnl Try to find the suffix with python-config otherwise give up AC_CACHE_CHECK([for Python extension suffix], [pc_cv_python_extension_suffix], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_extension_suffix=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --extension-suffix 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_extension_suffix= fi @@ -416,7 +422,7 @@ AC_DEFUN([PC_PYTHON_CHECK_ABI_FLAGS], dnl Try to find the ABI flags with python-config otherwise give up AC_CACHE_CHECK([for Python ABI flags], [pc_cv_python_abi_flags], [if test -x "$PYTHON_CONFIG"; then - pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>&AS_MESSAGE_LOG_FD` + pc_cv_python_abi_flags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --abiflags 2>&AS_MESSAGE_LOG_FD` else pc_cv_python_abi_flags= fi diff --git a/plugins/python/configure b/plugins/python/configure index e03d217e..39e94d8a 100755 --- a/plugins/python/configure +++ b/plugins/python/configure @@ -17008,6 +17008,11 @@ $as_echo "no" >&6; } fi +if test "xyes" = "xyes" && $PYTHON_CONFIGURE --embed; then : + PYTHON_EMBED_FLAG="--embed" +else + PYTHON_EMBED_FLAG="" +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python includes" >&5 $as_echo_n "checking for Python includes... " >&6; } @@ -17015,7 +17020,7 @@ if ${pc_cv_python_includes+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&5` + pc_cv_python_includes=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --includes 2>&5` else pc_cv_python_includes="-I$includedir/$_PYTHON_BASENAME" fi @@ -17041,7 +17046,7 @@ if ${pc_cv_python_cflags+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&5` + pc_cv_python_cflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --cflags 2>&5` else pc_cv_python_cflags= fi @@ -17057,7 +17062,7 @@ if ${pc_cv_python_ldflags+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&5` + pc_cv_python_ldflags=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --ldflags 2>&5` else pc_cv_python_ldflags= fi @@ -17073,7 +17078,7 @@ if ${pc_cv_python_libs+:} false; then : $as_echo_n "(cached) " >&6 else if test -x "$PYTHON_CONFIG"; then - pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&5` + pc_cv_python_libs=`$PYTHON_CONFIG $PYTHON_EMBED_FLAG --libs 2>&5` else pc_cv_python_libs="-l$_PYTHON_BASENAME" fi diff --git a/plugins/python/configure.ac b/plugins/python/configure.ac index 7d745780..bfe8ef56 100644 --- a/plugins/python/configure.ac +++ b/plugins/python/configure.ac @@ -84,7 +84,7 @@ AC_ARG_WITH([python], []) PC_PROG_PYTHON([python3], [2.7], [4.0]) -PC_PYTHON_PROG_PYTHON_CONFIG +PC_PYTHON_PROG_PYTHON_CONFIG([],[yes]) PC_PYTHON_CHECK_INCLUDES PC_PYTHON_CHECK_HEADERS PC_PYTHON_CHECK_CFLAGS