Skip to content

Commit

Permalink
Configure script updates
Browse files Browse the repository at this point in the history
* python-devel.m4: do not use distutils package, it is deprecated.

* Support to force installing to system or user site-packages with
  --enable-python-binding=sys|user

* Updated ax_ext.m4.
  • Loading branch information
gmarcais committed Sep 6, 2023
1 parent aa89c2a commit e9d5994
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AS_IF([test x$enable_all_static = xyes],
maybe_swig=
# --enable-python-binding
AC_ARG_ENABLE([python-binding],
[AS_HELP_STRING([--enable-python-binding@<:@=PATH@:>@],[create SWIG python module and install in PATH])])
[AS_HELP_STRING([--enable-python-binding@<:@=PATH@:>@],[create SWIG python module and install in PATH (user or system site-packages if PATH=user|sys)])])
# --enable-ruby-binding
AC_ARG_ENABLE([ruby-binding],
[AS_HELP_STRING([--enable-ruby-binding@<:@=PATH@:>@],[create SWIG ruby module and install in PATH])])
Expand Down
14 changes: 7 additions & 7 deletions m4/m4-ax_ext.m4
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 17
#serial 19

AC_DEFUN([AX_EXT],
[
Expand Down Expand Up @@ -160,22 +160,22 @@ AC_DEFUN([AX_EXT],
ax_cv_have_sse_os_support_ext=no,
if test "$((0x$edx_cpuid1>>25&0x01))" = 1; then
AC_LANG_PUSH([C])
AC_TRY_RUN([
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <signal.h>
#include <stdlib.h>
/* No way at ring1 to ring3 in protected mode to check the CR0 and CR4
control registers directly. Execute an SSE instruction.
If it raises SIGILL then OS doesn't support SSE based instructions */
void sig_handler(int signum){ exit(1); }
int main(){
int main(void){
signal(SIGILL, sig_handler);
/* SSE instruction xorps %xmm0,%xmm0 */
__asm__ __volatile__ (".byte 0x0f, 0x57, 0xc0");
return 0;
}],
ax_cv_have_sse_os_support_ext=yes,
ax_cv_have_sse_os_support_ext=no,
ax_cv_have_sse_os_support_ext=no)
}]])],
[ax_cv_have_sse_os_support_ext=yes],
[ax_cv_have_sse_os_support_ext=no],
[ax_cv_have_sse_os_support_ext=no])
AC_LANG_POP([C])
fi
])
Expand Down
61 changes: 34 additions & 27 deletions m4/m4-ax_python_devel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,31 @@ variable to configure. See ``configure --help'' for reference.
prefix=
fi
# Don't check for distutils, it is deprecated. Use module sysconfig and setuptools instead.
#
# Check if you have distutils, else fail
#
AC_MSG_CHECKING([for the distutils Python package])
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
if test -z "$ac_distutils_result"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot import Python module "distutils".
Please check your Python installation. The error was:
$ac_distutils_result])
PYTHON_VERSION=""
fi
# AC_MSG_CHECKING([for the sysconfig Python package])
# ac_distutils_result=`$PYTHON -c "import sysconfig" 2>&1`
# if test -z "$ac_distutils_result"; then
# AC_MSG_RESULT([yes])
# else
# AC_MSG_RESULT([no])
# AC_MSG_ERROR([cannot import Python module "distutils".
# Please check your Python installation. The error was:
# $ac_distutils_result])
# PYTHON_VERSION=""
# fi
#
# Check for Python include path
#
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));"`
python_path=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_path ('include'));"`
plat_python_path=`$PYTHON -c "import sysconfig; \
print (sysconfig.get_path ('platinclude'));"`
if test -n "${python_path}"; then
if test "${plat_python_path}" != "${python_path}"; then
python_path="-I$python_path -I$plat_python_path"
Expand All @@ -185,7 +186,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)
Expand All @@ -208,17 +209,17 @@ 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`
# 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:
Expand All @@ -237,7 +238,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_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
Expand All @@ -258,11 +259,17 @@ EOD`
#
AC_MSG_CHECKING([for Python site-packages path])
if test -z "$PYTHON_SITE_PKG"; then
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
PYTHON_SITE_PKG=`$PYTHON -c "import site; \
import sys; \
import os.path; \
pref=sys.argv.pop(); \
pref=pref if len(pref) > 0 and pref != '-c' else None; \
print(distutils.sysconfig.get_python_lib(0,0,pref));" $prefix`
path = os.path.join(pref, 'lib', 'python%d.%d' % sys.version_info@<:@:2@:>@) if pref else site.getsitepackages()@<:@0@:>@; \
print(path)" $prefix`
elif test "$PYTHON_SITE_PKG" = "user"; then
PYTHON_SITE_PKG=`$PYTHON -c "import site; print(site.getusersitepackages())"`
elif test "$PYTHON_SITE_PKG" = "sys"; then
PYTHON_SITE_PKG=`$PYTHON -c "import site; print(site.getsitepackages()@<:@0@:>@)"`
fi
AC_MSG_RESULT([$PYTHON_SITE_PKG])
AC_SUBST([PYTHON_SITE_PKG])
Expand All @@ -272,8 +279,8 @@ EOD`
#
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])
Expand All @@ -284,8 +291,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])
Expand Down

0 comments on commit e9d5994

Please sign in to comment.