aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in20
-rw-r--r--configure.ac217
-rw-r--r--m4/python.m4154
3 files changed, 303 insertions, 88 deletions
diff --git a/Makefile.in b/Makefile.in
index b9b91a0e..84ba3507 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -72,11 +72,11 @@ ifneq ($(VIRTUALENV),no)
else
$(PYTHON) $(srcdir)/setup.py install --prefix=$(DESTDIR)$(prefix)
endif
- if [[ $(DESTDIR)$(prefix) != $(abs_srcdir) ]]; then \
- $(INSTALL_DATA) $(srcdir)/Makefile $(DESTDIR)$(prefix)/Makefile; \
- $(INSTALL_DATA) $(srcdir)/lazycelery.sh $(DESTDIR)$(prefix)/lazycelery.sh; \
- $(INSTALL_DATA) $(srcdir)/lazyserver.sh $(DESTDIR)$(prefix)/lazyserver.sh; \
- fi
+# if [[ $(DESTDIR)$(prefix) != $(abs_srcdir) ]]; then \
+# $(INSTALL_DATA) $(srcdir)/Makefile $(DESTDIR)$(prefix)/Makefile; \
+# $(INSTALL_DATA) $(srcdir)/lazycelery.sh $(DESTDIR)$(prefix)/lazycelery.sh; \
+# $(INSTALL_DATA) $(srcdir)/lazyserver.sh $(DESTDIR)$(prefix)/lazyserver.sh; \
+# fi
# The same as "install", except use the "develop" setup.py target
develop: installdirs
@@ -102,13 +102,11 @@ endif
# should remove a basic package installed via setup.py, but please double- and
# triple-check it so that you don't remove something you shouldn't!
# Be sure to remove any extra files you install, such as binaries or documentation!
+#
# uninstall:
-# case $(prefix) in
-# /usr|/usr/local )
-# exit 1 ;;
-# /www/*|/srv/* )
-# rm -rvf $(prefix) ;;
-# esac
+# rm -rvf $(pkgpythondir)
+# rm -v $(pythondir)/$(PACKAGE_DISTNAME)-*.egg-info
+#
# Just use the usual setup.py clean command
clean:
diff --git a/configure.ac b/configure.ac
index b3933e88..396e7a5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ dnl----
dnl
AC_INIT([mediagoblin], [0.4.0.dev], [cwebber@gnu.org])
+
dnl----
dnl Load macros from the m4/ directory. If you plan to write new
dnl macros, put them in files in this directory.
@@ -71,7 +72,9 @@ dnl--PC_INIT----------------------------------------------------------
dnl This is the only required macro. Its primary function is to find
dnl a Python interpreter that is compatible with the package and set
dnl the PYTHON variable to hold its path. It can optionally take
-dnl arguments to specify minimum and/or maximum versions:
+dnl arguments to specify minimum and/or maximum versions. This is a
+dnl convenience macro that combines the functionality of the macros
+dnl PC_PROG_PYTHON and PC_PYTHON_VERIFY_VERSION
dnl PC_INIT: find an interpreter with a version between 2.0 and 3.3.99
dnl (in other words, up to and including any possible release
dnl in the 3.3 series)
@@ -81,7 +84,23 @@ dnl series and the max is in the 3.0 series, non-existent
dnl releases (2.8 & 2.9) will be correctly skipped.
dnl----
dnl
-PC_INIT([2.6], [2.7.99])
+PC_INIT([2.7], [3.3.1])
+
+
+dnl--PC_PROG_PYTHON---------------------------------------------------
+dnl This macro provides a means of finding a Python interpreter.
+dnl You may optionally pass it argument to pass a path to a binary to
+dnl check for first. You may also pass a second and third argument to
+dnl specify the minimum and maximum versions to check for. This works
+dnl in a naive way by appending the major and minor release numbers to
+dnl the binary name. By default, this will first check for a binary
+dnl called "python" and then from there it will check for version-
+dnl specific binaries (ie "python3", "python2.7") in decending version
+dnl order. Thus, the highest version binary will be found first.
+dnl----
+dnl
+dnl PC_PROG_PYTHON
+
dnl--PC_PYTHON_PROG_PYTHON_CONFIG-------------------------------------
dnl In order to use some of the other macros, you also need the
@@ -110,9 +129,9 @@ dnl
# Support installing to a virtualenv via the --with-virtualenv
# configure flag
AC_ARG_WITH([virtualenv],
- [AS_HELP_STRING([--without-virtualenv], [install to a Python virtualenv])],
+ [AS_HELP_STRING([--with-virtualenv], [install to a Python virtualenv])],
[],
- [with_virtualenv=yes])
+ [with_virtualenv=no])
AS_IF([test "x$with_virtualenv" != xno],
AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
AS_IF([test "x$VIRTUALENV" = xno],
@@ -152,6 +171,64 @@ AS_IF([test "x$SQLITE" = x -a "x$POSTGRES" = "x"],
[AC_MSG_ERROR([SQLite or PostgreSQL is required])])
+dnl#################################
+dnl Python installation properties #
+dnl#################################
+dnl
+dnl In this section, we test for various aspects of the Python
+dnl installation on the user's computer.
+
+dnl--PC_PYTHON_VERIFY_VERSION & PC_PYTHON_CHECK_VERSION----------------
+dnl PC_PYTHON_VERIFY_VERSION is used to check if the version of the
+dnl discovered Python binary meets some requirement. The first argument
+dnl should be a Python-compatible numerical comparison operator (i.e.
+dnl "==", "<", ">=", etc.). The second argument should be the version to
+dnl test against. Finally, you may optionally provide actions to take if
+dnl it does (3rd argument) or if it does not (4th argument) meet the
+dnl requirement.
+dnl
+dnl PC_PYTHON_CHECK_VERSION simply fetches the version number of the
+dnl Python interpreter stored in the PYTHON variable
+dnl----
+dnl
+dnl PC_PYTHON_VERIFY_VERSION([>=], [2.7.1], [AC_MSG_RESULT([yes])],
+dnl AC_MSG_FAILURE(Python 2 (python_min_ver+) is required))
+
+
+dnl--PC_PYTHON_CHECK_PREFIX--------------------------------------------
+dnl This macro finds out what Python thinks is the PREFIX
+dnl (i.e. /usr) and stores it in PYTHON_PREFIX. You probably shouldn't
+dnl use this and you should just stick to $prefix, but here it is
+dnl anyway.
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_PREFIX
+
+
+dnl--PC_PYTHON_CHECK_EXEC_PREFIX---------------------------------------
+dnl The same as above but for $exec-prefix
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_EXEC_PREFIX
+
+
+dnl--PC_PYTHON_CHECK_PLATFORM------------------------------------------
+dnl This macro checks what platform Python thinks this is (ie
+dnl "linux2") and stores it in PYTHON_PLATFORM
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_PLATFORM
+
+
+dnl--PC_PYTHON_CHECK_SITE_DIR------------------------------------------
+dnl This checks where Python packages are installed (usually
+dnl /usr/lib/pythonX.Y/site-packages) and stores it in the variable
+dnl pythondir.
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_SITE_DIR
+
+
dnl--PC_PYTHON_SITE_PACKAGE_DIR---------------------------------------
dnl This uses PYTHON_SITE_DIR to construct a directory for this
dnl project (ie $PYTHON_SITE_DIR/project_name) and stores it in
@@ -163,6 +240,14 @@ dnl----
dnl
PC_PYTHON_SITE_PACKAGE_DIR
+
+dnl--PC_PYTHON_CHECK_EXEC_DIR------------------------------------------
+dnl Same as PC_PYTHON_CHECK_SITE_DIR but for $exec-prefix. Stored in
+dnl pyexecdir
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_EXEC_DIR
+
dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
dnl pkgpyexecdir
@@ -183,6 +268,7 @@ dnl----
dnl
dnl PC_PYTHON_CHECK_MODULE([foo])
+
# Check for python-lxml module
PC_PYTHON_CHECK_MODULE([lxml], [],
[AC_MSG_ERROR([python-lxml is required])])
@@ -192,6 +278,129 @@ PC_PYTHON_CHECK_MODULE([Image], [],
[AC_MSG_ERROR([Python Imaging Library is required])])
+dnl--PC_PYTHON_CHECK_FUNC([PYTHON-MODULE], [FUNCTION], [ARGS],
+dnl [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAIL])
+dnl
+dnl This macro lets you test if a given function, possibly contained
+dnl in a given module, exists. If any exception is encountered when
+dnl calling this function, the check will fail.
+dnl----
+dnl
+dnl # test if Python library foo can do bar()
+dnl PC_PYTHON_CHECK_FUNC([foo], [bar])
+
+
+dnl Advanced notes:
+dnl m4/python.m4 implements Python as a language in Autoconf. This
+dnl means that you can use all the usual AC_LANG_* macros with Python
+dnl and it will behave as expected. In particular, this means that you
+dnl can run arbitrary Python code. For example:
+dnl
+dnl AC_LANG_PUSH(Python)[]
+dnl AC_RUN_IFELSE([AC_LANG_PROGRAM([dnl
+dnl # some code here
+dnl import foo
+dnl ], [dnl
+dnl # some more code here
+dnl foo.bar()
+dnl ])], [ACTION-IF-SUCCESSFUL], [ACTION-IF-FAILED])
+dnl AC_LANG_POP(Python)[]
+dnl
+dnl As usual, AC_LANG_PROGRAM takes two arguments, PROLOG code and
+dnl MAIN code. The PROLOG code goes verbatim at the top of the file,
+dnl while the MAIN code is embedded in an if __name__ == "__main__":
+dnl block. Python's indentation rules complicate things, however. In
+dnl particular, you must be sure that all of the code in MAIN is
+dnl indented once by default. PROLOG code does not require this.
+
+
+dnl##################################
+dnl Python module build environment #
+dnl##################################
+dnl
+dnl Here we check for necessary information for building Python modules
+dnl written in C
+
+dnl--PC_PYTHON_CHECK_INCLUDES------------------------------------------
+dnl This macro figures out the include flags necessary for loading the
+dnl Python headers (ie -I/usr/lib/python). The results are stored in
+dnl PYTHON_INCLUDES
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_INCLUDES
+
+
+dnl--PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])--
+dnl Using the information found from PC_PYTHON_CHECK_INCLUDES, check
+dnl to make sure that Python.h can be loaded. Note that if you use
+dnl this, you don't strictly need to also include
+dnl PC_PYTHON_CHECK_INCLUDES.
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
+
+
+dnl--PC_PYTHON_CHECK_LIBS----------------------------------------------
+dnl This checks what LIBS flags are necessary to use the Python
+dnl libraries (ie -lpython). The results are stored in PYTHON_LIBS
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_LIBS
+
+
+dnl--PC_PYTHON_TEST_LIBS([FUNCTION-TO-TEST], [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+dnl This checks whether the LIBS flag for libpython discovered with
+dnl PC_PYTHON_CHECK_LIBS is loadable and if a given function can be
+dnl found in the library. You may use this to test for the presence of
+dnl features in the library.
+dnl----
+dnl
+dnl PC_PYTHON_TEST_LIBS([PyObject_Print],,
+dnl [AC_MSG_ERROR(The Python library could not be loaded)])
+dnl # Add PYTHON_LIBS to LIBS
+dnl LIBS="$LIBS $PYTHON_LIBS"
+
+
+dnl--PC_PYTHON_CHECK_CFLAGS--------------------------------------------
+dnl This macro checks what Python thinks are the proper CFLAGS to
+dnl use and stores them in PYTHON_CFLAGS. Note that this info is only
+dnl available for Python versions which include a python-config tool
+dnl (2.5+).
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_CFLAGS
+dnl # Add PYTHON_CFLAGS to CFLAGS
+dnl CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+
+
+dnl--PC_PYTHON_CHECK_LDFLAGS-------------------------------------------
+dnl The same as above but for LDFLAGS
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_LDFLAGS
+dnl # Add PYTHON_LDFLAGS to LDFLAGS
+dnl LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
+
+
+dnl--PC_PYTHON_CHECK_EXTENSION_SUFFIX----------------------------------
+dnl This checks for what Python expects the suffix of extension
+dnl modules to be (i.e. .cpython-32mu.so) and stores it in
+dnl PYTHON_EXTENSION SUFFIX. This information is only available for
+dnl Python 3+
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_EXTENSION_SUFFIX
+
+
+dnl--PC_PYTHON_CHECK_ABI_FLAGS----------------------------------------
+dnl This checks for the ABI flags used by Python (i.e. "mu") and
+dnl stores it in PYTHON_ABI_FLAGS. This information is only available
+dnl for Python 3+
+dnl----
+dnl
+dnl PC_PYTHON_CHECK_ABI_FLAGS
+
+
dnl#########
dnl Finish #
dnl#########
diff --git a/m4/python.m4 b/m4/python.m4
index f8b197fe..58aef433 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -1,4 +1,4 @@
-# Copyright 2012, 2013 Brandon Invergo <brandon@invergo.net>
+# Copyright 2012, 2013, 2014 Brandon Invergo <brandon@invergo.net>
#
# This file is part of pyconfigure. This program is free
# software; you can redistribute it and/or modify it under the
@@ -107,69 +107,64 @@ m4_define([_AC_LANG_CALL(Python)],
AC_DEFUN([AC_LANG_COMPILER(Python)],
-[AC_REQUIRE([AC_PROG_PYTHON])])
+[AC_REQUIRE([PC_PROG_PYTHON])])
-# PC_INIT([MIN_VER], [MAX_VER])
+# PC_INIT([MIN-VERSION], [MAX-VERSION])
# -----------------------------
# Initialize pyconfigure, finding a Python interpreter with a given
# minimum and/or maximum version.
AC_DEFUN([PC_INIT],
-[AC_ARG_VAR([PYTHON], [the Python interpreter])
-dnl The default minimum version is 2.0
-m4_define_default([pc_min_ver], m4_ifval([$1], [$1], [2.0]))
-dnl The default maximum version is 3.3
-m4_define_default([pc_max_ver], m4_ifval([$2], [$2], [3.3]))
-dnl Build up a list of possible interpreter names.
-m4_define_default([_PC_PYTHON_INTERPRETER_LIST],
-dnl Construct a comma-separated list of interpreter names (python2.6,
-dnl python2.7, etc). We only care about the first 3 characters of the
-dnl version strings (major-dot-minor; not
-dnl major-dot-minor-dot-bugfix[-dot-whatever])
- [m4_foreach([pc_ver],
- m4_esyscmd_s(seq -s[[", "]] -f["[[%.1f]]"] m4_substr(pc_max_ver, [0], [3]) -0.1 m4_substr(pc_min_ver, [0], [3])),
-dnl Remove python2.8 and python2.9 since they will never exist
- [m4_bmatch(pc_ver, [2.[89]], [], [python]pc_ver)] ) \
-dnl If we want some Python 3 versions (max version >= 3.0),
-dnl also search for "python3"
-m4_if(m4_version_compare(pc_max_ver, [2.9]), [1], [python3], []) \
-dnl If we want some Python 2 versions (min version <= 2.7),
-dnl also search for "python2". Finally, also search for plain ol' "python"
-m4_if(m4_version_compare(pc_min_ver, [2.8]), [-1], [python2], []) [python]])
-dnl Do the actual search at last.
-AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])
+[PC_PROG_PYTHON([], [$1], [$2])
dnl If we found something, do a sanity check that the interpreter really
dnl has the version its name would suggest.
m4_ifval([PYTHON],
- [PC_PYTHON_VERIFY_VERSION([>=], [pc_min_ver],
- [AC_MSG_RESULT([yes])],
+ [PC_PYTHON_VERIFY_VERSION([>=], [pc_min_ver], [],
[AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
m4_ifval([PYTHON],
- [PC_PYTHON_VERIFY_VERSION([<=], [pc_max_ver],
- [AC_MSG_RESULT([yes])],
+ [PC_PYTHON_VERIFY_VERSION([<=], [pc_max_ver], [],
[AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
])# PC_INIT
-# AC_PROG_PYTHON(PROG-TO-CHECK-FOR)
+# PC_PROG_PYTHON([PROG-TO-CHECK-FOR], [MIN-VERSION], [MAX-VERSION])
# ---------------------------------
# Find a Python interpreter. Python versions prior to 2.0 are not
# supported. (2.0 was released on October 16, 2000).
-AC_DEFUN([AC_PROG_PYTHON],
+AC_DEFUN_ONCE([PC_PROG_PYTHON],
[AC_ARG_VAR([PYTHON], [the Python interpreter])
+dnl The default minimum version is 2.0
+m4_define_default([pc_min_ver], m4_ifval([$2], [$2], [2.0]))
+dnl The default maximum version is 3.3
+m4_define_default([pc_max_ver], m4_ifval([$3], [$3], [4.0]))
+dnl Build up a list of possible interpreter names.
m4_define_default([_PC_PYTHON_INTERPRETER_LIST],
- [python python3 python3.3 python3.2 python3.1 python3.0 python2 python2.7 dnl
- python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
+ [[python] \
+dnl If we want some Python 3 versions (max version >= 3.0),
+dnl also search for "python3"
+ m4_if(m4_version_compare(pc_max_ver, [2.9]), [1], [python3], []) \
+dnl If we want some Python 2 versions (min version <= 2.7),
+dnl also search for "python2".
+ m4_if(m4_version_compare(pc_min_ver, [2.8]), [-1], [python2], []) \
+dnl Construct a comma-separated list of interpreter names (python2.6,
+dnl python2.7, etc). We only care about the first 3 characters of the
+dnl version strings (major-dot-minor; not
+dnl major-dot-minor-dot-bugfix[-dot-whatever])
+ m4_foreach([pc_ver],
+ m4_esyscmd_s(seq -s[[", "]] -f["[[%.1f]]"] m4_substr(pc_max_ver, [0], [3]) -0.1 m4_substr(pc_min_ver, [0], [3])),
+dnl Remove python2.8 and python2.9 since they will never exist
+ [m4_bmatch(pc_ver, [2.[89]], [], [python]pc_ver)])])
+dnl Do the actual search at last.
m4_ifval([$1],
[AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
[AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
-])
+])# PC_PROG_PYTHON
# PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR)
# ----------------------------------------------
# Find the python-config program
AC_DEFUN([PC_PYTHON_PROG_PYTHON_CONFIG],
-[AC_REQUIRE([PC_INIT])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
AC_ARG_VAR([PYTHON_CONFIG], [the Python-config program])
dnl python-config's binary name is normally based on the Python interpreter's
dnl binary name (i.e. python2.7 -> python2.7-config)
@@ -180,9 +175,10 @@ m4_ifval([$1],
]) # PC_PYTHON_PROG_PYTHON_CONFIG
-# PC_PYTHON_VERIFY_VERSION(RELATION, VERSION, [ACTION-IF-TRUE], [ACTION-IF-NOT-FOUND])
+# PC_PYTHON_VERIFY_VERSION([RELATION], [VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ---------------------------------------------------------------------------
-# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version [RELATION] VERSION.
+# i.e if RELATION is "<", check if PROG has a version number less than VERSION.
# Run ACTION-IF-FALSE otherwise.
# Specify RELATION as any mathematical comparison "<", ">", "<=", ">=", "==" or "!="
# This test uses sys.hexversion instead of the string equivalent (first
@@ -191,7 +187,7 @@ m4_ifval([$1],
AC_DEFUN([PC_PYTHON_VERIFY_VERSION],
[m4_define([pc_python_safe_ver], m4_bpatsubsts($2, [\.], [_]))
AC_CACHE_CHECK([if Python $1 '$2'],
- [[pc_cv_python_min_version_]pc_python_safe_ver],
+ [[pc_cv_python_req_version_]pc_python_safe_ver],
[AC_LANG_PUSH(Python)[]dnl
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([dnl
@@ -205,13 +201,17 @@ import sys
# xrange is not present in Python 3.0 and range returns an iterator
for i in list(range(4)):
reqverhex = (reqverhex << 8) + reqver[[i]]
+ # the final 8 bits are "0xf0" for final versions, which are all
+ # we'll test against, since it's doubtful that a released software
+ # will depend on an alpha- or beta-state Python.
+ reqverhex += 0xf0
if sys.hexversion $1 reqverhex:
sys.exit()
else:
sys.exit(1)
])],
- [[pc_cv_python_req_version_]pc_python_safe_ver="yes"],
- [[pc_cv_python_req_version_]pc_python_safe_ver="no"])
+ [[pc_cv_python_req_version_]pc_python_safe_ver=yes],
+ [[pc_cv_python_req_version_]pc_python_safe_ver=no])
AC_LANG_POP(Python)[]dnl
])
AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3])
@@ -224,17 +224,17 @@ AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3]
# the best way to do this; it's what "site.py" does in the standard
# library.
AC_DEFUN([PC_PYTHON_CHECK_VERSION],
-[AC_REQUIRE([PC_INIT])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
AC_CACHE_CHECK([for $1 version],
[pc_cv_python_version],
[AC_LANG_PUSH(Python)[]dnl
- AC_LANG_CONFTEST([
- AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
], [dnl
sys.stdout.write(sys.version[[:3]])
-])])
- pc_cv_python_version=`$PYTHON conftest.py`
+])],
+ [pc_cv_python_version=`./conftest`],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
])
AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
@@ -255,11 +255,15 @@ AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix],
pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&AS_MESSAGE_LOG_FD`
else
AC_LANG_PUSH(Python)[]dnl
- pc_cv_python_prefix=AC_LANG_CONFTEST([AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
], [dnl
- sys.exit(sys.prefix)
-])])
+ sys.stdout.write(sys.prefix)
+])], [pc_cv_python_prefix=`./conftest`;
+ if test $? != 0; then
+ AC_MSG_FAILURE([could not determine Python prefix])
+ fi],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
fi])
AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
@@ -276,11 +280,16 @@ AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix],
pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>&AS_MESSAGE_LOG_FD`
else
AC_LANG_PUSH(Python)[]dnl
- pc_cv_python_exec_prefix=AC_LANG_CONFTEST([AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
], [dnl
- sys.exit(sys.exec_prefix)
-])])
+ sys.stdout.write(sys.exec_prefix)
+])],
+ [pc_cv_python_exec_prefix=`./conftest`;
+ if test $? != 0; then
+ AC_MSG_FAILURE([could not determine Python exec_prefix])
+ fi],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
fi
])
@@ -420,18 +429,19 @@ AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
# At times (like when building shared libraries) you may want
# to know which OS platform Python thinks this is.
AC_DEFUN([PC_PYTHON_CHECK_PLATFORM],
-[AC_REQUIRE([PC_INIT])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
dnl Get the platform from within Python (sys.platform)
-AC_CACHE_CHECK([for Python platform],
- [pc_cv_python_platform],
+AC_CACHE_CHECK([for Python platform], [pc_cv_python_platform],
[AC_LANG_PUSH(Python)[]dnl
- AC_LANG_CONFTEST([
- AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
], [dnl
sys.stdout.write(sys.platform)
-])])
- pc_cv_python_platform=`$PYTHON conftest.py`
+])], [pc_cv_python_platform=`./conftest`;
+ if test $? != 0; then
+ AC_MSG_FAILURE([could not determine Python platform])
+ fi],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
])
AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
@@ -443,7 +453,7 @@ AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
# The directory to which new libraries are installed (i.e. the
# "site-packages" directory.
AC_DEFUN([PC_PYTHON_CHECK_SITE_DIR],
-[AC_REQUIRE([PC_INIT])AC_REQUIRE([PC_PYTHON_CHECK_PREFIX])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_PREFIX])[]dnl
AC_CACHE_CHECK([for Python site-packages directory],
[pc_cv_python_site_dir],
[AC_LANG_PUSH(Python)[]dnl
@@ -453,8 +463,7 @@ AC_CACHE_CHECK([for Python site-packages directory],
else
pc_py_prefix=$prefix
fi
- AC_LANG_CONFTEST([
- AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
from platform import python_implementation
# sysconfig in CPython 2.7 doesn't work in virtualenv
@@ -475,8 +484,8 @@ else:
sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
], [dnl
sys.stdout.write(sitedir)
-])])
- pc_cv_python_site_dir=`$PYTHON conftest.py`
+])], [pc_cv_python_site_dir=`./conftest`],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
case $pc_cv_python_site_dir in
$pc_py_prefix*)
@@ -500,14 +509,14 @@ AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SI
# $PACKAGE directory under PYTHON_SITE_DIR
AC_DEFUN([PC_PYTHON_SITE_PACKAGE_DIR],
[AC_REQUIRE([PC_PYTHON_CHECK_SITE_DIR])[]dnl
-AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])])
+AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE_NAME])])
# PC_PYTHON_CHECK_EXEC_DIR
# ------------------------
# directory for installing python extension modules (shared libraries)
AC_DEFUN([PC_PYTHON_CHECK_EXEC_DIR],
-[AC_REQUIRE([PC_INIT])AC_REQUIRE([PC_PYTHON_CHECK_EXEC_PREFIX])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_EXEC_PREFIX])[]dnl
AC_CACHE_CHECK([for Python extension module directory],
[pc_cv_python_exec_dir],
[AC_LANG_PUSH(Python)[]dnl
@@ -517,8 +526,7 @@ AC_DEFUN([PC_PYTHON_CHECK_EXEC_DIR],
else
pc_py_exec_prefix=$pc_cv_python_exec_prefix
fi
- AC_LANG_CONFTEST([
- AC_LANG_PROGRAM([dnl
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
import sys
from platform import python_implementation
# sysconfig in CPython 2.7 doesn't work in virtualenv
@@ -539,8 +547,8 @@ else:
sitedir = sysconfig.get_path('purelib', vars={'platbase':'$pc_py_exec_prefix'})
], [dnl
sys.stdout.write(sitedir)
-])])
- pc_cv_python_exec_dir=`$PYTHON conftest.py`
+])], [pc_cv_python_exec_dir=`./conftest`],
+ [AC_MSG_FAILURE([failed to run Python program])])
AC_LANG_POP(Python)[]dnl
case $pc_cv_python_exec_dir in
$pc_py_exec_prefix*)
@@ -565,7 +573,7 @@ AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CH
# $PACKAGE directory under PYTHON_SITE_DIR
AC_DEFUN([PC_PYTHON_EXEC_PACKAGE_DIR],
[AC_REQUIRE([PC_PYTHON_CHECK_EXEC_DIR])[]dnl
-AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])])
+AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE_NAME])])
## -------------------------------------------- ##
@@ -577,7 +585,7 @@ AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])])
# ----------------------------------------------------------------------
# Macro for checking if a Python library is installed
AC_DEFUN([PC_PYTHON_CHECK_MODULE],
-[AC_REQUIRE([PC_INIT])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
AC_CACHE_CHECK([for Python '$1' library],
[[pc_cv_python_module_]pc_python_safe_mod],
@@ -605,7 +613,7 @@ AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
# Check to see if a given function call, optionally from a module, can
# be successfully called
AC_DEFUN([PC_PYTHON_CHECK_FUNC],
-[AC_REQUIRE([PC_INIT])[]dnl
+[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
AC_CACHE_CHECK([for Python m4_ifnblank($1, '$1.$2()', '$2()') function],
[[pc_cv_python_func_]pc_python_safe_mod[_$2]],