Python 2 and 3 testing on Windows
This commit is contained in:
parent
0f1e8f75da
commit
62fdff1bf3
1 changed files with 195 additions and 96 deletions
133
configure.ac
Normal file → Executable file
133
configure.ac
Normal file → Executable file
|
|
@ -601,6 +601,7 @@ AC_SUBST(TCLCXXSHARED)
|
||||||
|
|
||||||
PYINCLUDE=
|
PYINCLUDE=
|
||||||
PYLIB=
|
PYLIB=
|
||||||
|
PYLINK=
|
||||||
PYPACKAGE=
|
PYPACKAGE=
|
||||||
|
|
||||||
AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python])
|
AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python])
|
||||||
|
|
@ -617,15 +618,49 @@ else
|
||||||
PYTHON="$PYBIN"
|
PYTHON="$PYBIN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PYVER=0
|
||||||
if test -n "$PYTHON"; then
|
if test -n "$PYTHON"; then
|
||||||
|
AC_MSG_CHECKING([for $PYTHON major version number])
|
||||||
|
PYVER=`($PYTHON -c "import sys; sys.stdout.write(sys.version[[0]])") 2>/dev/null`
|
||||||
|
AC_MSG_RESULT($PYVER)
|
||||||
|
if test -z "$PYVER"; then
|
||||||
|
PYVER=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $PYVER -le 2; then
|
||||||
AC_MSG_CHECKING(for Python prefix)
|
AC_MSG_CHECKING(for Python prefix)
|
||||||
PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
|
PYPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.prefix)") 2>/dev/null`
|
||||||
AC_MSG_RESULT($PYPREFIX)
|
AC_MSG_RESULT($PYPREFIX)
|
||||||
AC_MSG_CHECKING(for Python exec-prefix)
|
AC_MSG_CHECKING(for Python exec-prefix)
|
||||||
PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
|
PYEPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)") 2>/dev/null`
|
||||||
AC_MSG_RESULT($PYEPREFIX)
|
AC_MSG_RESULT($PYEPREFIX)
|
||||||
|
AC_MSG_CHECKING(for Python os.name)
|
||||||
|
PYOSNAME=`($PYTHON -c "import sys, os; sys.stdout.write(os.name)")`
|
||||||
|
AC_MSG_RESULT($PYOSNAME)
|
||||||
|
|
||||||
|
if test x"$PYOSNAME" = x"nt"; then
|
||||||
|
# Windows installations are quite different to posix installations
|
||||||
|
PYPREFIX=`echo "$PYPREFIX" | sed -e 's,\\\\,/,g'` # Forward slashes are easier to use and even work on Windows most of the time
|
||||||
|
PYTHON_SO=.pyd
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for Python header files)
|
||||||
|
if test -r $PYPREFIX/include/Python.h; then
|
||||||
|
PYINCLUDE="-I$PYPREFIX/include"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT($PYINCLUDE)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for Python library directory)
|
||||||
|
if test -d $PYPREFIX/libs; then
|
||||||
|
PYLIB=$PYPREFIX/libs
|
||||||
|
PYLINKFILE=`ls $PYLIB/python*.lib | grep "python[[0-9]][[0-9]]\.lib"`
|
||||||
|
if test -r "$PYLINKFILE"; then
|
||||||
|
PYLINK=-l`basename $PYLINKFILE | sed -e 's/\.lib$//'`
|
||||||
|
else
|
||||||
|
PYLIB=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
# Note: I could not think of a standard way to get the version string from different versions.
|
# Note: I could not think of a standard way to get the version string from different versions.
|
||||||
# This trick pulls it out of the file location for a standard library file.
|
# This trick pulls it out of the file location for a standard library file.
|
||||||
|
|
||||||
|
|
@ -633,13 +668,13 @@ else
|
||||||
|
|
||||||
# Need to do this hack since autoconf replaces __file__ with the name of the configure file
|
# Need to do this hack since autoconf replaces __file__ with the name of the configure file
|
||||||
filehack="file__"
|
filehack="file__"
|
||||||
PYVERSION=`($PYTHON -c "import string,operator,os.path; print operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1)")`
|
PYVERSION=`($PYTHON -c "import sys,string,operator,os.path; sys.stdout.write(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")`
|
||||||
AC_MSG_RESULT($PYVERSION)
|
AC_MSG_RESULT($PYVERSION)
|
||||||
|
|
||||||
# Find the directory for libraries this is necessary to deal with
|
# Find the directory for libraries this is necessary to deal with
|
||||||
# platforms that can have apps built for multiple archs: e.g. x86_64
|
# platforms that can have apps built for multiple archs: e.g. x86_64
|
||||||
AC_MSG_CHECKING(for Python lib dir)
|
AC_MSG_CHECKING(for Python lib dir)
|
||||||
PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null`
|
PYLIBDIR=`($PYTHON -c "import sys; sys.stdout.write(sys.lib)") 2>/dev/null`
|
||||||
if test -z "$PYLIBDIR"; then
|
if test -z "$PYLIBDIR"; then
|
||||||
# Fedora patch Python to add sys.lib, for other distros we assume "lib".
|
# Fedora patch Python to add sys.lib, for other distros we assume "lib".
|
||||||
PYLIBDIR="lib"
|
PYLIBDIR="lib"
|
||||||
|
|
@ -660,7 +695,7 @@ else
|
||||||
AC_MSG_RESULT($PYINCLUDE)
|
AC_MSG_RESULT($PYINCLUDE)
|
||||||
|
|
||||||
# Set the library directory blindly. This probably won't work with older versions
|
# Set the library directory blindly. This probably won't work with older versions
|
||||||
AC_MSG_CHECKING(for Python library)
|
AC_MSG_CHECKING(for Python library directory)
|
||||||
dirs="$PYVERSION/config $PYVERSION/$PYLIBDIR python/$PYLIBDIR"
|
dirs="$PYVERSION/config $PYVERSION/$PYLIBDIR python/$PYLIBDIR"
|
||||||
for i in $dirs; do
|
for i in $dirs; do
|
||||||
if test -d $PYEPREFIX/$PYLIBDIR/$i; then
|
if test -d $PYEPREFIX/$PYLIBDIR/$i; then
|
||||||
|
|
@ -668,13 +703,21 @@ else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
PYLINK="-l$PYVERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
if test -z "$PYLIB"; then
|
if test -z "$PYLIB"; then
|
||||||
AC_MSG_RESULT(Not found)
|
AC_MSG_RESULT(Not found)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT($PYLIB)
|
AC_MSG_RESULT($PYLIB)
|
||||||
fi
|
fi
|
||||||
|
AC_MSG_CHECKING(for Python library)
|
||||||
PYLINK="-l$PYVERSION"
|
if test -z "$PYLINK"; then
|
||||||
|
AC_MSG_RESULT(Not found)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT($PYLINK)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cygwin (Windows) needs the library for dynamic linking
|
# Cygwin (Windows) needs the library for dynamic linking
|
||||||
|
|
@ -697,11 +740,9 @@ AC_SUBST(PYTHONDYNAMICLINKING)
|
||||||
# Look for Python 3.x
|
# Look for Python 3.x
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
|
|
||||||
# mostly copy & pasted from "Look for Python" section,
|
|
||||||
# did some trim, fix and rename
|
|
||||||
|
|
||||||
PY3INCLUDE=
|
PY3INCLUDE=
|
||||||
PY3LIB=
|
PY3LIB=
|
||||||
|
PY3LINK=
|
||||||
PY3PACKAGE=
|
PY3PACKAGE=
|
||||||
|
|
||||||
AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support])
|
AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support])
|
||||||
|
|
@ -712,7 +753,7 @@ if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then
|
||||||
AC_MSG_NOTICE([Disabling Python 3.x support])
|
AC_MSG_NOTICE([Disabling Python 3.x support])
|
||||||
else
|
else
|
||||||
if test "x$PY3BIN" = xyes; then
|
if test "x$PY3BIN" = xyes; then
|
||||||
for py_ver in 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0; do
|
for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 ""; do
|
||||||
AC_CHECK_PROGS(PYTHON3, [python$py_ver])
|
AC_CHECK_PROGS(PYTHON3, [python$py_ver])
|
||||||
if test -n "$PYTHON3"; then
|
if test -n "$PYTHON3"; then
|
||||||
AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config])
|
AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config])
|
||||||
|
|
@ -726,8 +767,58 @@ else
|
||||||
AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config])
|
AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PYVER=0
|
||||||
|
if test -n "$PYTHON3"; then
|
||||||
|
AC_MSG_CHECKING([for $PYTHON3 major version number])
|
||||||
|
PYVER=`($PYTHON3 -c "import sys; sys.stdout.write(sys.version[[0]])") 2>/dev/null`
|
||||||
|
AC_MSG_RESULT($PYVER)
|
||||||
|
if test -z "$PYVER"; then
|
||||||
|
PYVER=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then
|
if test $PYVER -ge 3; then
|
||||||
|
AC_MSG_CHECKING(for Python 3.x os.name)
|
||||||
|
PY3OSNAME=`($PYTHON3 -c "import sys, os; sys.stdout.write(os.name)")`
|
||||||
|
AC_MSG_RESULT($PY3OSNAME)
|
||||||
|
|
||||||
|
if test x"$PY3OSNAME" = x"nt"; then
|
||||||
|
# Windows installations are quite different to posix installations
|
||||||
|
# There is no python-config to use
|
||||||
|
AC_MSG_CHECKING(for Python 3.x prefix)
|
||||||
|
PY3PREFIX=`($PYTHON3 -c "import sys; sys.stdout.write(sys.prefix)") 2>/dev/null`
|
||||||
|
AC_MSG_RESULT($PY3PREFIX)
|
||||||
|
PY3PREFIX=`echo "$PY3PREFIX" | sed -e 's,\\\\,/,g'` # Forward slashes are easier to use and even work on Windows most of the time
|
||||||
|
PYTHON_SO=.pyd
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for Python 3.x header files)
|
||||||
|
if test -r $PY3PREFIX/include/Python.h; then
|
||||||
|
PY3INCLUDE="-I$PY3PREFIX/include"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT($PY3INCLUDE)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for Python 3.x library directory)
|
||||||
|
if test -d $PY3PREFIX/libs; then
|
||||||
|
PY3LIB=$PY3PREFIX/libs
|
||||||
|
PY3LINKFILE=`ls $PY3LIB/python*.lib | grep "python[[0-9]][[0-9]]\.lib"`
|
||||||
|
if test -r "$PY3LINKFILE"; then
|
||||||
|
PY3LINK=-l`basename $PY3LINKFILE | sed -e 's/\.lib$//'`
|
||||||
|
else
|
||||||
|
PY3LIB=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test -z "$PY3LIB"; then
|
||||||
|
AC_MSG_RESULT([Not found])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT($PY3LIB)
|
||||||
|
fi
|
||||||
|
AC_MSG_CHECKING([for Python 3.x library])
|
||||||
|
if test -z "$PY3LINK"; then
|
||||||
|
AC_MSG_RESULT(Not found)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT($PY3LINK)
|
||||||
|
fi
|
||||||
|
elif test -n "$PY3CONFIG"; then
|
||||||
AC_MSG_CHECKING([for Python 3.x prefix])
|
AC_MSG_CHECKING([for Python 3.x prefix])
|
||||||
PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null`
|
PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null`
|
||||||
AC_MSG_RESULT($PY3PREFIX)
|
AC_MSG_RESULT($PY3PREFIX)
|
||||||
|
|
@ -762,7 +853,7 @@ else
|
||||||
AC_MSG_RESULT($PY3INCLUDE)
|
AC_MSG_RESULT($PY3INCLUDE)
|
||||||
|
|
||||||
# Set the library directory blindly. This probably won't work with older versions
|
# Set the library directory blindly. This probably won't work with older versions
|
||||||
AC_MSG_CHECKING([for Python 3.x library])
|
AC_MSG_CHECKING([for Python 3.x library directory])
|
||||||
dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR"
|
dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR"
|
||||||
for i in $dirs; do
|
for i in $dirs; do
|
||||||
if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then
|
if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then
|
||||||
|
|
@ -777,12 +868,20 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PY3LINK="-l$PY3VERSION"
|
PY3LINK="-l$PY3VERSION"
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for Python 3.x library])
|
||||||
|
if test -z "$PY3LINK"; then
|
||||||
|
AC_MSG_RESULT(Not found)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT($PY3LINK)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cygwin (Windows) needs the library for dynamic linking
|
# Cygwin (Windows) needs the library for dynamic linking
|
||||||
case $host in
|
case $host in
|
||||||
*-*-cygwin* | *-*-mingw*)
|
*-*-cygwin* | *-*-mingw*)
|
||||||
PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK"
|
PYTHON3DYNAMICLINKING="-L$PY3LIB $PY3LINK"
|
||||||
DEFS="-DUSE_DL_IMPORT $DEFS"
|
DEFS="-DUSE_DL_IMPORT $DEFS"
|
||||||
;;
|
;;
|
||||||
*)PYTHON3DYNAMICLINKING="";;
|
*)PYTHON3DYNAMICLINKING="";;
|
||||||
|
|
@ -2512,14 +2611,14 @@ AC_SUBST(SKIP_OCTAVE)
|
||||||
|
|
||||||
|
|
||||||
SKIP_PYTHON=
|
SKIP_PYTHON=
|
||||||
if (test -z "$PYINCLUDE") &&
|
if (test -z "$PYINCLUDE" || test -z "$PYLINK") &&
|
||||||
(test -z "$PY3INCLUDE") ; then
|
(test -z "$PY3INCLUDE" || test -z "$PY3LINK") ; then
|
||||||
SKIP_PYTHON="1"
|
SKIP_PYTHON="1"
|
||||||
fi
|
fi
|
||||||
AC_SUBST(SKIP_PYTHON)
|
AC_SUBST(SKIP_PYTHON)
|
||||||
|
|
||||||
SKIP_PYTHON3=
|
SKIP_PYTHON3=
|
||||||
if test -z "$PY3INCLUDE" ; then
|
if test -z "$PY3INCLUDE" || test -z "$PY3LINK" ; then
|
||||||
SKIP_PYTHON3="1"
|
SKIP_PYTHON3="1"
|
||||||
fi
|
fi
|
||||||
AC_SUBST(SKIP_PYTHON3)
|
AC_SUBST(SKIP_PYTHON3)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue