Update configure script for python detection. It requires changes in ldns Makefile as well. Make ldnsx platform independent module, but keep ldns as platform dependent.
326 lines
12 KiB
Diff
326 lines
12 KiB
Diff
From 61a166ef79b74d50e4151844a2c33dfa2b8f7e53 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
|
Date: Tue, 3 Jan 2023 20:09:00 +0100
|
|
Subject: [PATCH] Update python configuration, support platform site dir
|
|
|
|
Update to the most recent ax_python_devel.m4 from autoconf-archive
|
|
2022.09.03. It reports two separate directories, one for platform
|
|
independent files, another for platform specific files.
|
|
|
|
Make sure native code library installs into platform site directory.
|
|
Python modules can be installed into common site directory. Should work
|
|
on python 3.12, which removes distutils module completely.
|
|
---
|
|
ldns-1.8.3/Makefile.in | 13 ++-
|
|
ldns-1.8.3/ax_python_devel.m4 | 147 +++++++++++++++++++++++++++-------
|
|
2 files changed, 127 insertions(+), 33 deletions(-)
|
|
|
|
diff --git a/ldns-1.8.3/Makefile.in b/ldns-1.8.3/Makefile.in
|
|
index 57957d0..e70602d 100644
|
|
--- a/ldns-1.8.3/Makefile.in
|
|
+++ b/ldns-1.8.3/Makefile.in
|
|
@@ -21,6 +21,7 @@ PERL = @PERL@
|
|
swig = @swig@
|
|
swigpy_flags = -python @SWIGPY3@
|
|
python_site = @PYTHON_SITE_PKG@
|
|
+python_platform_site = @PYTHON_PLATFORM_SITE_PKG@
|
|
pyldns_inst = @PYLDNSINST@
|
|
pyldns_uninst = @PYLDNSUNINST@
|
|
pyldnsx_inst = @PYLDNSXINST@
|
|
@@ -324,7 +325,7 @@ ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c ldns/config.h
|
|
$(COMP_LIB) -I./include/ldns $(LIBSSL_CPPFLAGS) $(PYTHON_CPPFLAGS) $(PYTHON_X_CFLAGS) -c $(pywrapdir)/ldns_wrapper.c -o $@
|
|
|
|
_ldns.la: ldns_wrapper.lo libldns.la
|
|
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(PYTHON_CFLAGS) $(LDFLAGS) -module -version-info $(version_info) -no-undefined -o $@ ldns_wrapper.lo -rpath $(python_site) -L. -L.libs $(LIB) $(PYTHON_LIBS) $(LIBS)
|
|
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(PYTHON_CFLAGS) $(LDFLAGS) -module -version-info $(version_info) -no-undefined -o $@ ldns_wrapper.lo -rpath $(python_platform_site) -L. -L.libs $(LIB) $(PYTHON_LIBS) $(LIBS)
|
|
|
|
$(p5_dns_ldns_dir)/Makefile: $(p5_dns_ldns_dir)/Makefile.PL
|
|
BUILDDIR=`pwd`; cd $(p5_dns_ldns_dir); LD_LIBRARY_PATH="$$BUILDDIR/.libs:$$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="$$BUILDDIR/.libs:$$DYLD_LIBRARY_PATH" $(PERL) Makefile.PL LIBS="-L$$BUILDDIR/.libs -lldns" INC="-I$$BUILDDIR"
|
|
@@ -414,15 +415,19 @@ uninstall-lib:
|
|
|
|
install-pyldns: @PYLDNS@
|
|
$(INSTALL) -m 755 -d $(DESTDIR)$(python_site)/ldns
|
|
- $(INSTALL) -c -m 644 $(pywrapdir)/ldns.py $(DESTDIR)$(python_site)/ldns.py
|
|
- $(LIBTOOL) --mode=install cp _ldns.la $(DESTDIR)$(python_site)
|
|
- $(LIBTOOL) --mode=finish $(DESTDIR)$(python_site)
|
|
+ $(INSTALL) -m 755 -d $(DESTDIR)$(python_platform_site)
|
|
+ $(INSTALL) -c -m 644 $(pywrapdir)/ldns.py $(DESTDIR)$(python_platform_site)/ldns.py
|
|
+ $(LIBTOOL) --mode=install cp _ldns.la $(DESTDIR)$(python_platform_site)
|
|
+ $(LIBTOOL) --mode=finish $(DESTDIR)$(python_platform_site)
|
|
|
|
uninstall-pyldns:
|
|
rm -f $(DESTDIR)$(python_site)/ldns/*
|
|
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(python_platform_site)/_ldns.la
|
|
+ rm -f $(DESTDIR)$(python_platform_site)/ldns.py
|
|
test ! -d $(DESTDIR)$(python_site)/ldns || rmdir $(DESTDIR)$(python_site)/ldns || echo "ok, dir already gone"
|
|
|
|
install-pyldnsx:
|
|
+ $(INSTALL) -m 755 -d $(DESTDIR)$(python_site)
|
|
$(INSTALL) -c -m 644 $(pyldnsxwrapdir)/ldnsx.py $(DESTDIR)$(python_site)/ldnsx.py
|
|
|
|
uninstall-pyldnsx:
|
|
diff --git a/ldns-1.8.3/ax_python_devel.m4 b/ldns-1.8.3/ax_python_devel.m4
|
|
index aff04f6..780584e 100644
|
|
--- a/ldns-1.8.3/ax_python_devel.m4
|
|
+++ b/ldns-1.8.3/ax_python_devel.m4
|
|
@@ -67,7 +67,7 @@
|
|
# modified version of the Autoconf Macro, you may extend this special
|
|
# exception to the GPL to apply to your modified version as well.
|
|
|
|
-#serial 21
|
|
+#serial 32
|
|
|
|
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
|
|
AC_DEFUN([AX_PYTHON_DEVEL],[
|
|
@@ -112,15 +112,39 @@ to something else than an empty string.
|
|
fi
|
|
|
|
#
|
|
- # if the macro parameter ``version'' is set, honour it
|
|
+ # If the macro parameter ``version'' is set, honour it.
|
|
+ # A Python shim class, VPy, is used to implement correct version comparisons via
|
|
+ # string expressions, since e.g. a naive textual ">= 2.7.3" won't work for
|
|
+ # Python 2.7.10 (the ".1" being evaluated as less than ".3").
|
|
#
|
|
if test -n "$1"; then
|
|
AC_MSG_CHECKING([for a version of Python $1])
|
|
- ac_supports_python_ver=`$PYTHON -c "import sys; \
|
|
- ver = sys.version.split ()[[0]]; \
|
|
+ cat << EOF > ax_python_devel_vpy.py
|
|
+class VPy:
|
|
+ def vtup(self, s):
|
|
+ return tuple(map(int, s.strip().replace("rc", ".").split(".")))
|
|
+ def __init__(self):
|
|
+ import sys
|
|
+ self.vpy = tuple(sys.version_info)
|
|
+ def __eq__(self, s):
|
|
+ return self.vpy == self.vtup(s)
|
|
+ def __ne__(self, s):
|
|
+ return self.vpy != self.vtup(s)
|
|
+ def __lt__(self, s):
|
|
+ return self.vpy < self.vtup(s)
|
|
+ def __gt__(self, s):
|
|
+ return self.vpy > self.vtup(s)
|
|
+ def __le__(self, s):
|
|
+ return self.vpy <= self.vtup(s)
|
|
+ def __ge__(self, s):
|
|
+ return self.vpy >= self.vtup(s)
|
|
+EOF
|
|
+ ac_supports_python_ver=`$PYTHON -c "import ax_python_devel_vpy; \
|
|
+ ver = ax_python_devel_vpy.VPy(); \
|
|
print (ver $1)"`
|
|
+ rm -rf ax_python_devel_vpy*.py* __pycache__/ax_python_devel_vpy*.py*
|
|
if test "$ac_supports_python_ver" = "True"; then
|
|
- AC_MSG_RESULT([yes])
|
|
+ AC_MSG_RESULT([yes])
|
|
else
|
|
AC_MSG_RESULT([no])
|
|
AC_MSG_ERROR([this package requires Python $1.
|
|
@@ -135,16 +159,25 @@ variable to configure. See ``configure --help'' for reference.
|
|
#
|
|
# Check if you have distutils, else fail
|
|
#
|
|
- AC_MSG_CHECKING([for the distutils Python package])
|
|
- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
|
|
+ AC_MSG_CHECKING([for the sysconfig Python package])
|
|
+ ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1`
|
|
if test $? -eq 0; then
|
|
AC_MSG_RESULT([yes])
|
|
+ IMPORT_SYSCONFIG="import sysconfig"
|
|
else
|
|
AC_MSG_RESULT([no])
|
|
- AC_MSG_ERROR([cannot import Python module "distutils".
|
|
+
|
|
+ AC_MSG_CHECKING([for the distutils Python package])
|
|
+ ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1`
|
|
+ if test $? -eq 0; then
|
|
+ AC_MSG_RESULT([yes])
|
|
+ IMPORT_SYSCONFIG="from distutils import sysconfig"
|
|
+ else
|
|
+ AC_MSG_ERROR([cannot import Python module "distutils".
|
|
Please check your Python installation. The error was:
|
|
-$ac_distutils_result])
|
|
- PYTHON_VERSION=""
|
|
+$ac_sysconfig_result])
|
|
+ PYTHON_VERSION=""
|
|
+ fi
|
|
fi
|
|
|
|
#
|
|
@@ -152,10 +185,19 @@ $ac_distutils_result])
|
|
#
|
|
AC_MSG_CHECKING([for Python include path])
|
|
if test -z "$PYTHON_CPPFLAGS"; then
|
|
- python_path=`$PYTHON -c "import distutils.sysconfig; \
|
|
- print (distutils.sysconfig.get_python_inc ());"`
|
|
- plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
|
|
- print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
|
|
+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
|
|
+ # sysconfig module has different functions
|
|
+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_path ('include'));"`
|
|
+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_path ('platinclude'));"`
|
|
+ else
|
|
+ # old distutils way
|
|
+ python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_python_inc ());"`
|
|
+ plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_python_inc (plat_specific=1));"`
|
|
+ fi
|
|
if test -n "${python_path}"; then
|
|
if test "${plat_python_path}" != "${python_path}"; then
|
|
python_path="-I$python_path -I$plat_python_path"
|
|
@@ -179,7 +221,7 @@ $ac_distutils_result])
|
|
|
|
# join all versioning strings, on some systems
|
|
# major/minor numbers could be in different list elements
|
|
-from distutils.sysconfig import *
|
|
+from sysconfig import *
|
|
e = get_config_var('VERSION')
|
|
if e is not None:
|
|
print(e)
|
|
@@ -190,7 +232,7 @@ EOD`
|
|
ac_python_version=$PYTHON_VERSION
|
|
else
|
|
ac_python_version=`$PYTHON -c "import sys; \
|
|
- print (sys.version[[:3]])"`
|
|
+ print ("%d.%d" % sys.version_info[[:2]])"`
|
|
fi
|
|
fi
|
|
|
|
@@ -202,8 +244,8 @@ EOD`
|
|
ac_python_libdir=`cat<<EOD | $PYTHON -
|
|
|
|
# There should be only one
|
|
-import distutils.sysconfig
|
|
-e = distutils.sysconfig.get_config_var('LIBDIR')
|
|
+$IMPORT_SYSCONFIG
|
|
+e = sysconfig.get_config_var('LIBDIR')
|
|
if e is not None:
|
|
print (e)
|
|
EOD`
|
|
@@ -211,8 +253,8 @@ EOD`
|
|
# Now, for the library:
|
|
ac_python_library=`cat<<EOD | $PYTHON -
|
|
|
|
-import distutils.sysconfig
|
|
-c = distutils.sysconfig.get_config_vars()
|
|
+$IMPORT_SYSCONFIG
|
|
+c = sysconfig.get_config_vars()
|
|
if 'LDVERSION' in c:
|
|
print ('python'+c[['LDVERSION']])
|
|
else:
|
|
@@ -231,7 +273,7 @@ EOD`
|
|
else
|
|
# old way: use libpython from python_configdir
|
|
ac_python_libdir=`$PYTHON -c \
|
|
- "from distutils.sysconfig import get_python_lib as f; \
|
|
+ "from sysconfig import get_python_lib as f; \
|
|
import os; \
|
|
print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
|
|
PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
|
|
@@ -252,19 +294,66 @@ EOD`
|
|
#
|
|
AC_MSG_CHECKING([for Python site-packages path])
|
|
if test -z "$PYTHON_SITE_PKG"; then
|
|
- PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
|
|
- print (distutils.sysconfig.get_python_lib(1,0));"`
|
|
+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
|
|
+ PYTHON_SITE_PKG=`$PYTHON -c "
|
|
+$IMPORT_SYSCONFIG;
|
|
+if hasattr(sysconfig, 'get_default_scheme'):
|
|
+ scheme = sysconfig.get_default_scheme()
|
|
+else:
|
|
+ scheme = sysconfig._get_default_scheme()
|
|
+if scheme == 'posix_local':
|
|
+ # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
|
|
+ scheme = 'posix_prefix'
|
|
+prefix = '$prefix'
|
|
+if prefix == 'NONE':
|
|
+ prefix = '$ac_default_prefix'
|
|
+sitedir = sysconfig.get_path('purelib', scheme, vars={'base': prefix})
|
|
+print(sitedir)"`
|
|
+ else
|
|
+ # distutils.sysconfig way
|
|
+ PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_python_lib(0,0));"`
|
|
+ fi
|
|
fi
|
|
AC_MSG_RESULT([$PYTHON_SITE_PKG])
|
|
AC_SUBST([PYTHON_SITE_PKG])
|
|
|
|
+ #
|
|
+ # Check for platform-specific site packages
|
|
+ #
|
|
+ AC_MSG_CHECKING([for Python platform specific site-packages path])
|
|
+ if test -z "$PYTHON_PLATFORM_SITE_PKG"; then
|
|
+ if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then
|
|
+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "
|
|
+$IMPORT_SYSCONFIG;
|
|
+if hasattr(sysconfig, 'get_default_scheme'):
|
|
+ scheme = sysconfig.get_default_scheme()
|
|
+else:
|
|
+ scheme = sysconfig._get_default_scheme()
|
|
+if scheme == 'posix_local':
|
|
+ # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
|
|
+ scheme = 'posix_prefix'
|
|
+prefix = '$prefix'
|
|
+if prefix == 'NONE':
|
|
+ prefix = '$ac_default_prefix'
|
|
+sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase': prefix})
|
|
+print(sitedir)"`
|
|
+ else
|
|
+ # distutils.sysconfig way
|
|
+ PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ print (sysconfig.get_python_lib(1,0));"`
|
|
+ fi
|
|
+ fi
|
|
+ AC_MSG_RESULT([$PYTHON_PLATFORM_SITE_PKG])
|
|
+ AC_SUBST([PYTHON_PLATFORM_SITE_PKG])
|
|
+
|
|
#
|
|
# libraries which must be linked in when embedding
|
|
#
|
|
AC_MSG_CHECKING(python extra libraries)
|
|
if test -z "$PYTHON_EXTRA_LIBS"; then
|
|
- PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
|
|
- conf = distutils.sysconfig.get_config_var; \
|
|
+ PYTHON_EXTRA_LIBS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ conf = sysconfig.get_config_var; \
|
|
print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
|
|
fi
|
|
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
|
|
@@ -275,8 +364,8 @@ EOD`
|
|
#
|
|
AC_MSG_CHECKING(python extra linking flags)
|
|
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
|
|
- PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
|
|
- conf = distutils.sysconfig.get_config_var; \
|
|
+ PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "$IMPORT_SYSCONFIG; \
|
|
+ conf = sysconfig.get_config_var; \
|
|
print (conf('LINKFORSHARED'))"`
|
|
fi
|
|
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
|
|
@@ -290,7 +379,7 @@ EOD`
|
|
ac_save_LIBS="$LIBS"
|
|
ac_save_LDFLAGS="$LDFLAGS"
|
|
ac_save_CPPFLAGS="$CPPFLAGS"
|
|
- LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS"
|
|
+ LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS"
|
|
LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
|
|
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
|
|
AC_LANG_PUSH([C])
|
|
@@ -306,7 +395,7 @@ EOD`
|
|
|
|
AC_MSG_RESULT([$pythonexists])
|
|
|
|
- if test ! "x$pythonexists" = "xyes"; then
|
|
+ if test ! "x$pythonexists" = "xyes"; then
|
|
AC_MSG_FAILURE([
|
|
Could not link test program to Python. Maybe the main Python library has been
|
|
installed in some non-standard library path. If so, pass it to configure,
|
|
--
|
|
2.38.1
|
|
|