diff --git a/python-config-wrapper b/python-config-wrapper new file mode 100755 index 0000000..c00e8ea --- /dev/null +++ b/python-config-wrapper @@ -0,0 +1,35 @@ +#!/bin/sh +# python3-config wrapper script to support Python 3.8 +# Works around https://bugs.python.org/issue36721 + +set -e + +usage() { + echo "Usage: $0 [python3-config] (--libs|--includes)" + exit 1 +} + +if [ $# -ne 2 ]; then + usage +fi + +PYTHON_CONFIG="$1" +shift + +WHICH_FLAG="$1" +shift + +case "$WHICH_FLAG" in + --libs) + # Python 3.8 needs --embed, but previous versions do not have it: + # https://github.com/python/cpython/pull/13500 + "$PYTHON_CONFIG" --ldflags --libs --embed 2>/dev/null || + "$PYTHON_CONFIG" --ldflags --libs + ;; + --includes) + "$PYTHON_CONFIG" --includes + ;; + *) + usage + ;; +esac diff --git a/python.pri b/python.pri index 05a90f1..80efc2f 100644 --- a/python.pri +++ b/python.pri @@ -4,5 +4,5 @@ isEmpty(PYTHON_CONFIG) { message(PYTHON_CONFIG = $$PYTHON_CONFIG) -QMAKE_LIBS += $$system($$PYTHON_CONFIG --ldflags --libs) -QMAKE_CXXFLAGS += $$system($$PYTHON_CONFIG --includes) +QMAKE_LIBS += $$system($$PWD/python-config-wrapper $$PYTHON_CONFIG --libs) +QMAKE_CXXFLAGS += $$system($$PWD/python-config-wrapper $$PYTHON_CONFIG --includes)