From 3941218a0266895a097a5e9daae97d9a4a78430d Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Fri, 31 Mar 2023 18:55:29 +0200 Subject: [PATCH] bind: add support for PEP-632 Signed-off-by: Sebastien Binet --- bind/utils.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bind/utils.go b/bind/utils.go index 42ef5bc..02620d6 100644 --- a/bind/utils.go +++ b/bind/utils.go @@ -103,7 +103,13 @@ func (pc *PyConfig) AllFlags() string { // python VM (python, python2, python3, pypy, etc...) func GetPythonConfig(vm string) (PyConfig, error) { code := `import sys -import distutils.sysconfig as ds +try: + import sysconfig as ds + def _get_python_inc(): + return ds.get_path('include') +except ImportError: + import distutils.sysconfig as ds + _get_python_inc = ds.get_config_var import json import os version=sys.version_info.major @@ -133,7 +139,7 @@ else: print(json.dumps({ "version": sys.version_info.major, "minor": sys.version_info.minor, - "incdir": ds.get_python_inc(), + "incdir": _get_python_inc(), "libdir": ds.get_config_var("LIBDIR"), "libpy": ds.get_config_var("LIBRARY"), "shlibs": ds.get_config_var("SHLIBS"),