Annotation of pgsql/config/python.m4, revision 1.17
1.1 petere 1: #
2: # Autoconf macros for configuring the build of Python extension modules
3: #
1.17 ! petere 4: # $PostgreSQL: pgsql/config/python.m4,v 1.16 2009/10/14 21:59:15 petere Exp $
1.1 petere 5: #
6:
1.2 petere 7: # PGAC_PATH_PYTHON
1.1 petere 8: # ----------------
1.4 petere 9: # Look for Python and set the output variable 'PYTHON'
10: # to 'python' if found, empty otherwise.
1.2 petere 11: AC_DEFUN([PGAC_PATH_PYTHON],
12: [AC_PATH_PROG(PYTHON, python)
13: if test x"$PYTHON" = x""; then
14: AC_MSG_ERROR([Python not found])
15: fi
16: ])
17:
18:
19: # _PGAC_CHECK_PYTHON_DIRS
20: # -----------------------
1.11 tgl 21: # Determine the name of various directories of a given Python installation.
1.2 petere 22: AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
23: [AC_REQUIRE([PGAC_PATH_PYTHON])
1.8 joe 24: AC_MSG_CHECKING([for Python distutils module])
1.16 petere 25: if "${PYTHON}" -c 'import distutils' 2>&AS_MESSAGE_LOG_FD
1.8 joe 26: then
27: AC_MSG_RESULT(yes)
28: else
29: AC_MSG_RESULT(no)
30: AC_MSG_ERROR([distutils module not found])
31: fi
1.10 tgl 32: AC_MSG_CHECKING([Python configuration directory])
1.17 ! petere 33: python_majorversion=`${PYTHON} -c "import sys; print(sys.version[[0]])"`
1.15 petere 34: python_version=`${PYTHON} -c "import sys; print(sys.version[[:3]])"`
35: python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print(os.path.join(f(plat_specific=1,standard_lib=1),'config'))"`
36: python_includespec=`${PYTHON} -c "import distutils.sysconfig; print('-I'+distutils.sysconfig.get_python_inc())"`
1.2 petere 37:
1.17 ! petere 38: AC_SUBST(python_majorversion)[]dnl
1.10 tgl 39: AC_SUBST(python_version)[]dnl
1.2 petere 40: AC_SUBST(python_configdir)[]dnl
1.3 petere 41: AC_SUBST(python_includespec)[]dnl
42: # This should be enough of a message.
1.10 tgl 43: AC_MSG_RESULT([$python_configdir])
1.2 petere 44: ])# _PGAC_CHECK_PYTHON_DIRS
45:
46:
47: # PGAC_CHECK_PYTHON_EMBED_SETUP
48: # -----------------------------
1.11 tgl 49: #
50: # Note: selecting libpython from python_configdir works in all Python
51: # releases, but it generally finds a non-shared library, which means
52: # that we are binding the python interpreter right into libplpython.so.
53: # In Python 2.3 and up there should be a shared library available in
54: # the main library location.
1.2 petere 55: AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
56: [AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
57: AC_MSG_CHECKING([how to link an embedded Python application])
1.5 petere 58:
1.15 petere 59: python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR'))))"`
60: python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
61: python_so=`${PYTHON} -c "import distutils.sysconfig,string; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
1.11 tgl 62: ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
63:
64: if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
65: then
66: # New way: use the official shared library
67: ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
68: python_libspec="-L${python_libdir} -l${ldlibrary}"
69: else
70: # Old way: use libpython from python_configdir
71: python_libdir="${python_configdir}"
72: python_libspec="-L${python_libdir} -lpython${python_version}"
73: fi
74:
1.15 petere 75: python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS'))))"`
1.2 petere 76:
1.11 tgl 77: AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
1.2 petere 78:
1.11 tgl 79: AC_SUBST(python_libdir)[]dnl
1.2 petere 80: AC_SUBST(python_libspec)[]dnl
1.11 tgl 81: AC_SUBST(python_additional_libs)[]dnl
1.12 momjian 82:
83: # threaded python is not supported on bsd's
84: AC_MSG_CHECKING(whether Python is compiled with thread support)
1.15 petere 85: pythreads=`${PYTHON} -c "import sys; print(int('thread' in sys.builtin_module_names))"`
1.12 momjian 86: if test "$pythreads" = "1"; then
87: AC_MSG_RESULT(yes)
88: case $host_os in
1.14 petere 89: openbsd*|freebsd*)
90: AC_MSG_ERROR([threaded Python not supported on this platform])
1.12 momjian 91: ;;
92: esac
93: else
94: AC_MSG_RESULT(no)
95: fi
96:
1.2 petere 97: ])# PGAC_CHECK_PYTHON_EMBED_SETUP
PostgreSQL CVSweb <[email protected]>