浏览代码

app_python3: update Python3 detection mechanism

This commit

  - removes the python calls whose output is never actually used.

  - changes the include discovery to use python3(.x)-config. This is
    preferable because it also works for cross-compiling. Calling
    python3(.x) directly will always provide host flags, which for
    cross-compiling is not feasible.

  - updates LDFLAGS discovery to also work with >= Python 3.8. To
    achieve this python3(.x)-config is first run with the argument
    "--embed". If this does not succeed (exit status 1)
    python3(.x)-config is run again without "--embed". This is the
    method suggested by Python upstream to provide backwards
    compatibility. See [1] for more details.

[1] https://docs.python.org/3/whatsnew/3.8.html

Signed-off-by: Sebastian Kemper <[email protected]>
Sebastian Kemper 5 年之前
父节点
当前提交
05af36d34a
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 5 7
      src/modules/app_python3/Makefile

+ 5 - 7
src/modules/app_python3/Makefile

@@ -11,18 +11,16 @@ NAME=app_python3.so
 # but no testing has been done with that.
 # but no testing has been done with that.
 PYTHON3?=python3
 PYTHON3?=python3
 
 
-PYTHON3_VERSION=${shell ${PYTHON3} -c "import distutils.sysconfig;print(distutils.sysconfig.get_config_var('VERSION'))"}
-PYTHON3_LIBDIR=${shell ${PYTHON3} -c "import distutils.sysconfig;print(distutils.sysconfig.get_config_var('LIBDIR'))"}
-PYTHON3_LDFLAGS=${shell ${PYTHON3} -c "import distutils.sysconfig;print(distutils.sysconfig.get_config_var('LINKFORSHARED'))"}
-PYTHON3_INCDIR=${shell ${PYTHON3} -c "import distutils.sysconfig;print(distutils.sysconfig.get_python_inc())"}
-
-LIBS=${shell ${PYTHON3}-config --ldflags}
+LIBS=${shell \
+	tmp_py3_libs=$$(${PYTHON3}-config --ldflags --embed) || \
+	tmp_py3_libs=$$(${PYTHON3}-config --ldflags); \
+	echo $$tmp_py3_libs}
 
 
 ifeq ($(OS), freebsd)
 ifeq ($(OS), freebsd)
 LIBS+=-pthread
 LIBS+=-pthread
 endif
 endif
 
 
-DEFS+=-I${PYTHON3_INCDIR}
+DEFS+=${shell ${PYTHON3}-config --includes}
 
 
 include ../../Makefile.modules
 include ../../Makefile.modules