aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--Makefile.in207
-rw-r--r--PKG-INFO19
-rwxr-xr-xbootstrap.sh3
-rw-r--r--configure.ac202
-rw-r--r--docs/source/siteadmin/deploying.rst15
-rwxr-xr-xinstall-sh527
-rw-r--r--m4/python.m4638
8 files changed, 1617 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 85de0102..b2189f82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,14 @@
/kombu.db
/server-log.txt
+# pyconfigure/automake generated files
+/Makefile
+/autom4te.cache/
+/config.log
+/config.status
+/configure
+/aclocal.m4
+
# Tests
/mediagoblin/tests/user_dev/
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 00000000..a79d6cbc
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,207 @@
+# Makefile.in
+#
+# Copyright © 2012, 2013 Brandon Invergo <brandon@invergo.net>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+
+# List whatever files you want to include in your source distribution here.
+# You can include whole directories but note that *everything* under that
+# directory will be included
+DISTFILES = PKG-INFO Makefile.in configure setup.py install-sh
+
+DESTDIR =
+VPATH = @srcdir@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_DISTNAME = ${PACKAGE_NAME}-${PACKAGE_VERSION}
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PYTHON = @PYTHON@
+VIRTUALENV = @VIRTUALENV@
+SPHINXBUILD = @SPHINXBUILD@
+POSTGRES = @POSTGRES@
+SHELL = @SHELL@
+MKDIR_P = @MKDIR_P@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+prefix = @prefix@
+srcdir = @srcdir@
+abs_srcdir = @abs_srcdir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+pythondir = @pythondir@
+pyexecdir = @pyexecdir@
+pkgdatadir = $(datadir)/@PACKAGE_NAME@
+pkgincludedir = $(includedir)/@PACKAGE_NAME@
+pkgpythondir = @pkgpythondir@
+pkgpyexecdir = @pkgpyexecdir@
+PYTHONPATH = $(pythondir)$(PATH_SEPARATOR)$(DESTDIR)$(pythondir)
+
+all: install
+
+.PHONY: all install develop uninstall distclean info install-html html \
+install-pdf pdf install-dvi dvi install-ps ps clean dist check \
+installdirs postgresql update
+
+# Since installing to a virtualenv is all the rage these days, support
+# it here. If the VIRTUALENV variable is set to anything other than
+# "no", set up a new virtualenv and install there, otherwise install
+# as usual from setup.py
+install: installdirs
+ $(NORMAL_INSTALL)
+ifneq ($(VIRTUALENV),no)
+ $(VIRTUALENV) $(VIRTUALENV_FLAGS) --python=$(PYTHON) \
+ --system-site-packages $(DESTDIR)$(prefix) || \
+ $(VIRTUALENV) $(DESTDIR)$(prefix)
+ $(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py install \
+ --prefix=$(DESTDIR)$(prefix)
+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
+
+# The same as "install", except use the "develop" setup.py target
+develop: installdirs
+ $(NORMAL_INSTALL)
+ifneq ($(VIRTUALENV),no)
+ $(VIRTUALENV) $(VIRTUALENV_FLAGS) --python=$(PYTHON) \
+ --system-site-packages $(DESTDIR)$(prefix) || \
+ $(VIRTUALENV) $(DESTDIR)$(prefix)
+ $(DESTDIR)$(prefix)/bin/python $(srcdir)/setup.py develop \
+ --prefix=$(DESTDIR)$(prefix)
+else
+ $(PYTHON) $(srcdir)/setup.py develop --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
+
+
+# setup.py doesn't (yet) support an uninstall command, so until it does, you
+# must manually remove everything that was installed here. The following example
+# 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
+
+# Just use the usual setup.py clean command
+clean:
+ $(PYTHON) setup.py clean
+
+
+# Clean up the output of configure
+distclean:
+ rm -v $(srcdir)/config.log
+ rm -v $(srcdir)/config.status
+ rm -rvf $(srcdir)/autom4te.cache
+ rm -v $(srcdir)/aclocal.m4
+ rm -v $(srcdir)/Makefile
+
+# You can either use the setup.py sdist command or you can roll your own here
+dist:
+# $(PYTHON) setup.py sdist
+ mkdir $(PACKAGE_DISTNAME)
+ cp -r $(DISTFILES) $(PACKAGE_DISTNAME)
+ tar -czf $(PACKAGE_DISTNAME).tar.gz $(PACKAGE_DISTNAME)
+ rm -rf $(PACKAGE_DISTNAME)
+
+# Use the setup.py check command
+check:
+ $(PYTHON) setup.py check
+
+# setup.py might complain if a directory doesn't exist so just in case, make the directory
+# here
+installdirs:
+ $(MKDIR_P) $(DESTDIR)$(prefix)
+
+# Set up PostgreSQL
+postgresql:
+ sudo -u $(POSTGRES) createuser mediagoblin
+ sudo -u $(POSTGRES) createdb -E UNICODE -O mediagoblin mediagoblin
+
+update:
+ifneq ($(VIRTUALENV),no)
+ $(prefix)/bin/python $(srcdir)/setup.py develop --prefix=$(prefix) --upgrade
+else
+ $(PYTHON) $(srcdir)/setup.py develop --prefix=$(prefix) --upgrade
+endif
+ $(prefix)/bin/gmg dbupdate
+
+# The following show how to install documentation. In this example,
+# docs are built from a separate Makefile contained in the docs
+# directory which uses the SPHINXBUILD variable to store the location
+# of the sphinx-build (Python doc tool) binary to use.
+
+$(DESTDIR)$(infodir)/mediagoblin.info: docs/build/texinfo/mediagoblin.info
+ $(POST_INSTALL)
+ $(INSTALL_DATA) @< $(DESTDIR)$@
+ if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then
+ install-info --dir-file=$(DESTDIR)$(infodir)/dir \
+ $(DESTDIR)$(infodir)/foo.info;
+ else true; fi
+
+info: docs/build/texinfo/mediagoblin.info
+
+docs/build/texinfo/mediagoblin.info: $(wildcard docs/source/*)
+ifneq ($(SPHINXBUILD),no)
+ $(MAKE) -C docs info SPHINXBUILD=$(SPHINXBUILD)
+endif
+
+
+install-html: html installdirs
+ $(INSTALL_DATA) docs/build/html/* $(DESTDIR)$(htmldir)
+
+html: docs/build/html/index.html
+
+docs/build/html/index.html: $(wildcard $(srcdir)/docs/source/*)
+ifneq ($(SPHINXBUILD),no)
+ $(MAKE) -C docs html SPHINXBUILD=$(SPHINXBUILD)
+endif
+
+
+install-pdf: pdf installdirs
+ $(INSTALL_DATA) docs/build/latex/mediagoblin.pdf $(DESTDIR)$(pdfdir)
+
+pdf: docs/build/latex/mediagoblin.pdf
+
+docs/build/latex/mediagoblin.pdf: $(wildcard $(srcdir)/docs/source/*)
+ifneq ($(SPHINXBUILD),no)
+ $(MAKE) -C docs latexpdf SPHINXBUILD=$(SPHINXBUILD)
+endif
+
+
+install-dvi:
+
+dvi:
+
+install-ps:
+
+ps:
+
+
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 00000000..24fb75b1
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,19 @@
+Metadata-Version: 1.2
+Name: mediagoblin
+Version: 0.4.0.dev
+Summary: UNKNOWN
+Home-page: http://mediagoblin.org/
+Author: Free Software Foundation and contributors
+Author-email: cwebber@gnu.org
+License: AGPLv3
+Download-URL: http://mediagoblin.org/download/
+Description:
+Platform: UNKNOWN
+Classifier: Development Status :: 3 - Alpha
+Classifier: Environment :: Web Environment
+Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 00000000..1540ea4b
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+autoreconf -fvi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 00000000..e56a55a5
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,202 @@
+dnl configure.ac
+dnl
+dnl Copyright 2012, 2013 Brandon Invergo <brandon@invergo.net>
+dnl
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved. This file is offered as-is,
+dnl without any warranty.
+
+dnl#########
+dnl README #
+dnl#########
+dnl
+dnl This is a basic Autoconf configure.ac file for Python-based
+dnl projects. It is not intended to be used as-is, but rather to be
+dnl modified to the specific needs of the project.
+dnl
+dnl Lines prefixed with "dnl" are comments that are automatically
+dnl removed by Autoconf/M4, thus they will not appear in the generated
+dnl configure script (see the M4 documentation for more information).
+dnl Such comments are used in this file to communicate information to
+dnl you, the developer. In some cases, the comments contain extra
+dnl macros that you might consider including in your configure script.
+dnl If you wish to include them, simply remove the "dnl" from the
+dnl beginning of the line.
+dnl
+dnl Lines prefixed with "#" are comments that will appear in the
+dnl generated configure script. These comments are thus used to clarify
+dnl to the user what is happening in that script
+dnl
+dnl Wherever pyconfigure-specific macros are used, extra comments are
+dnl included to describe the macros.
+
+dnl######################
+dnl Package Information #
+dnl######################
+
+dnl----
+dnl Initialize Autoconf with the package metadata
+dnl The arguments have been set via the project's PKG-INFO file
+dnl and correspond to:
+dnl
+dnl 1) package name (i.e. foo)
+dnl 2) package version (i.e. 1.2)
+dnl 3) bug/info/project email address (i.e. bug-foo@gnu.org)
+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.
+dnl----
+dnl
+AC_CONFIG_MACRO_DIR([m4])
+
+
+# The default prefix should be changed from /usr/local. Set it, as in
+# the documentation, to /srv/mediagoblin.example.org/mediagoblin/
+AC_PREFIX_DEFAULT([`pwd`])
+
+
+dnl###########################
+dnl Program/command support #
+dnl###########################
+dnl
+dnl In this section, we check for the presence of important commands
+dnl and programs.
+
+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 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)
+dnl PC_INIT([MIN_VER], [MAX_VER]): Find an interpreter that is between
+dnl the minimum and maximum version. If the min is in the 2.0
+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])
+
+dnl--PC_PYTHON_PROG_PYTHON_CONFIG-------------------------------------
+dnl In order to use some of the other macros, you also need the
+dnl python-config command, which will fall subject to the same problem
+dnl of python3-config being preferred to python2-config. This macro
+dnl will be automatically included if you use on of the macros that
+dnl depends on it, so you normally don't have to call it. However, if
+dnl you require a specific version, you can do something like the
+dnl following example.
+dnl----
+dnl
+PC_PYTHON_PROG_PYTHON_CONFIG([python2-config])
+if [[ "x$PYTHON_CONFIG" == "x" ]]; then
+ PC_PYTHON_PROG_PYTHON_CONFIG([$PYTHON-config])
+fi
+
+dnl----
+dnl With the following set of macros, we implement an option
+dnl "--with-virtualenv", which the user can pass to the configure
+dnl script in order to install to a Virtualenv (AC_ARG_WITH). If the
+dnl option is specified by the user, then we check if the program is
+dnl available, checking both for "virtualenv" and "virtualenv2"
+dnl (AC_CHECK_PROGS)
+dnl----
+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])],
+ [],
+ [with_virtualenv=yes])
+AS_IF([test "x$with_virtualenv" != xno],
+ AC_CHECK_PROGS([VIRTUALENV], [virtualenv virtualenv3 virtualenv2], [no])
+ AS_IF([test "x$VIRTUALENV" = xno],
+ [AC_MSG_FAILURE(
+ [--with-virtualenv given but virtualenv could not be found])]),
+ AC_SUBST([VIRTUALENV], [no]))
+AC_ARG_VAR([VIRTUALENV_FLAGS], [flags to pass to the virtualenv command])
+
+dnl----
+dnl If the program uses sphinx-build to build documentation, uncomment
+dnl this to create a SPHINXBUILD variable in the Makefile pointing to
+dnl the program. Thus, the user would specify
+dnl SPHINXBUILD=/path/to/sphinx-build as an argument to the configure
+dnl script. Since building the documentation should be optional, just
+dnl print a warning. If the program uses some other documentation
+dnl system, you can do something similar with it.
+dnl----
+dnl
+# Check for sphinx-build
+AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
+AS_IF([test "x$SPHINXBUILD" = xno],
+ AC_MSG_WARN(sphinx-build is required to build documentation))
+
+
+dnl----
+dnl These two are standard Autoconf macros which check for the
+dnl presence of some programs that we will use in the Makefile.
+dnl----
+dnl
+AC_PROG_MKDIR_P
+AC_PROG_INSTALL
+
+# Check for a supported database program
+AC_PATH_PROG([SQLITE], [sqlite3])
+AC_PATH_PROG([POSTGRES], [postgres])
+AS_IF([test "x$SQLITE" = x -a "x$POSTGRES" = "x"],
+ [AC_MSG_ERROR([SQLite or PostgreSQL is required])])
+
+
+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
+dnl pkgpythondir. This value is used by Automake for installing Python
+dnl scripts. By default, this begins with $pythondir, unexpanded, to
+dnl provide compatibility with GNU Makefile specifications, allowing
+dnl the user to change the prefix from the commandline.
+dnl----
+dnl
+PC_PYTHON_SITE_PACKAGE_DIR
+
+dnl--PC_PYTHON_EXEC_PACKAGE_DIR----------------------------------------
+dnl Same as PC_PYTHON_SITE_PACKAGE_DIR but for $exec-prefix. Stored in
+dnl pkgpyexecdir
+dnl----
+dnl
+PC_PYTHON_EXEC_PACKAGE_DIR
+
+
+dnl###############################
+dnl Checking Python capabilities #
+dnl###############################
+
+dnl--PC_PYTHON_CHECK_MODULE([PYTHON-MODULE], [ACTION-IF-PRESENT],
+dnl [ACTION-IF-ABSENT])
+dnl This macro lets you check if a given Python module exists on the
+dnl system.
+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])])
+
+# Check for the Python Imaging Library
+PC_PYTHON_CHECK_MODULE([Image], [],
+ [AC_MSG_ERROR([Python Imaging Library is required])])
+
+
+dnl#########
+dnl Finish #
+dnl#########
+
+dnl Define the files to be configured
+AC_CONFIG_FILES([Makefile])
+dnl Generate config.status
+AC_OUTPUT
diff --git a/docs/source/siteadmin/deploying.rst b/docs/source/siteadmin/deploying.rst
index 2f68912d..6123dc9e 100644
--- a/docs/source/siteadmin/deploying.rst
+++ b/docs/source/siteadmin/deploying.rst
@@ -203,12 +203,23 @@ Clone the MediaGoblin repository and set up the git submodules::
cd mediagoblin
git submodule init && git submodule update
-Set up the in-package virtualenv::
+Set up the in-package virtualenv via make::
- (virtualenv --system-site-packages . || virtualenv .) && ./bin/python setup.py develop
+ ./bootstrap.sh && ./configure && make
.. note::
+ Prefer not to use make, or want to use the "old way" of installing
+ MediaGoblin (maybe you know how to use virtualenv and python
+ packaging)? You still can! All that the above make script is doing
+ is installing an in-package virtualenv and running
+
+ ./bin/python setup.py develop
+
+.. ::
+
+ (NOTE: Is this still relevant?)
+
If you have problems here, consider trying to install virtualenv
with the ``--distribute`` or ``--no-site-packages`` options. If
your system's default Python is in the 3.x series you may need to
diff --git a/install-sh b/install-sh
new file mode 100755
index 00000000..377bb868
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,527 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2011-11-20.07; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# 'make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call 'install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ do_exit='(exit $ret); exit $ret'
+ trap "ret=129; $do_exit" 1
+ trap "ret=130; $do_exit" 2
+ trap "ret=141; $do_exit" 13
+ trap "ret=143; $do_exit" 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names problematic for 'test' and other utilities.
+ case $src in
+ -* | [=\(\)!]) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+ dst=$dst_arg
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ [-=\(\)!]*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test X"$d" = X && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/m4/python.m4 b/m4/python.m4
new file mode 100644
index 00000000..f8b197fe
--- /dev/null
+++ b/m4/python.m4
@@ -0,0 +1,638 @@
+# Copyright 2012, 2013 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
+# terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the Autoconf Configure Script Exception,
+# version 3.0, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License
+# and a copy of the Autoconf Configure Script Exception along with
+# this program; see the files COPYINGv3 and COPYING.EXCEPTION
+# respectively. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Many of these macros were adapted from ones written by Andrew Dalke
+# and James Henstridge and are included with the Automake utility
+# under the following copyright terms:
+#
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Table of Contents:
+#
+# 1. Language selection
+# and routines to produce programs in a given language.
+#
+# 2. Producing programs in a given language.
+#
+# 3. Looking for a compiler
+# And possibly the associated preprocessor.
+#
+# 4. Looking for specific libs & functionality
+
+
+## ----------------------- ##
+## 1. Language selection. ##
+## ----------------------- ##
+
+
+# AC_LANG(Python)
+# ---------------
+AC_LANG_DEFINE([Python], [py], [PY], [PYTHON], [],
+[ac_ext=py
+ac_compile='chmod +x conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&AS_MESSAGE_LOG_FD'
+])
+
+
+# AC_LANG_PYTHON
+# --------------
+AU_DEFUN([AC_LANG_PYTHON], [AC_LANG(Python)])
+
+
+## ----------------------- ##
+## 2. Producing programs. ##
+## ----------------------- ##
+
+
+# AC_LANG_PROGRAM(Python)([PROLOGUE], [BODY])
+# -------------------------------------------
+m4_define([AC_LANG_PROGRAM(Python)], [dnl
+@%:@!$PYTHON
+$1
+m4_if([$2], [], [], [dnl
+if __name__ == '__main__':
+$2])])
+
+
+# _AC_LANG_IO_PROGRAM(Python)
+# ---------------------------
+# Produce source that performs I/O.
+m4_define([_AC_LANG_IO_PROGRAM(Python)],
+[AC_LANG_PROGRAM([dnl
+import sys
+try:
+ h = open('conftest.out')
+except:
+ sys.exit(1)
+else:
+ close(h)
+ sys.exit(0)
+], [])])
+
+
+# _AC_LANG_CALL(Python)([PROLOGUE], [FUNCTION])
+# ---------------------
+# Produce source that calls FUNCTION
+m4_define([_AC_LANG_CALL(Python)],
+[AC_LANG_PROGRAM([$1], [$2])])
+
+
+## -------------------------------------------- ##
+## 3. Looking for Compilers and Interpreters. ##
+## -------------------------------------------- ##
+
+
+AC_DEFUN([AC_LANG_COMPILER(Python)],
+[AC_REQUIRE([AC_PROG_PYTHON])])
+
+
+# PC_INIT([MIN_VER], [MAX_VER])
+# -----------------------------
+# 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])
+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])],
+ [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])],
+ [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)
+# ---------------------------------
+# 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_ARG_VAR([PYTHON], [the Python interpreter])
+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])
+m4_ifval([$1],
+ [AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
+ [AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
+])
+
+
+# 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_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)
+m4_define([_PYTHON_BASENAME], [`basename $PYTHON`])
+m4_ifval([$1],
+ [AC_PATH_PROGS(PYTHON_CONFIG, [$1 _PYTHON_BASENAME-config])],
+ [AC_PATH_PROG(PYTHON_CONFIG, _PYTHON_BASENAME-config)])
+]) # PC_PYTHON_PROG_PYTHON_CONFIG
+
+
+# PC_PYTHON_VERIFY_VERSION(RELATION, VERSION, [ACTION-IF-TRUE], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-FALSE otherwise.
+# Specify RELATION as any mathematical comparison "<", ">", "<=", ">=", "==" or "!="
+# This test uses sys.hexversion instead of the string equivalent (first
+# word of sys.version), in order to cope with versions such as 2.2c1.
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
+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],
+ [AC_LANG_PUSH(Python)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+ # split strings by '.' and convert to numeric. Append some zeros
+ # because we need at least 4 digits for the hex conversion.
+ # map returns an iterator in Python 3.0 and a list in 2.x
+ reqver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
+ reqverhex = 0
+ # xrange is not present in Python 3.0 and range returns an iterator
+ for i in list(range(4)):
+ reqverhex = (reqverhex << 8) + reqver[[i]]
+ 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"])
+ AC_LANG_POP(Python)[]dnl
+ ])
+AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3])
+])# PC_PYTHON_VERIFY_VERSION
+
+
+# PC_PYTHON_CHECK_VERSION
+# -----------------------
+# Query Python for its version number. Getting [:3] seems to be
+# 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_CACHE_CHECK([for $1 version],
+ [pc_cv_python_version],
+ [AC_LANG_PUSH(Python)[]dnl
+ AC_LANG_CONFTEST([
+ AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+ sys.stdout.write(sys.version[[:3]])
+])])
+ pc_cv_python_version=`$PYTHON conftest.py`
+ AC_LANG_POP(Python)[]dnl
+ ])
+AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
+])# PC_PYTHON_CHECK_VERSION
+
+
+# PC_PYTHON_CHECK_PREFIX
+# ----------------------
+# Use the value of $prefix for the corresponding value of
+# PYTHON_PREFIX. This is made a distinct variable so it can be
+# overridden if need be. However, general consensus is that you
+# shouldn't need this ability.
+AC_DEFUN([PC_PYTHON_CHECK_PREFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to get it with python-config otherwise do it from within Python
+AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix],
+[if test -x "$PYTHON_CONFIG"; then
+ 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
+import sys
+], [dnl
+ sys.exit(sys.prefix)
+])])
+ AC_LANG_POP(Python)[]dnl
+fi])
+AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
+
+
+# PC_PYTHON_CHECK_EXEC_PREFIX
+# --------------------------
+# Like above, but for $exec_prefix
+AC_DEFUN([PC_PYTHON_CHECK_EXEC_PREFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to get it with python-config otherwise do it from within Python
+AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix],
+[if test -x "$PYTHON_CONFIG"; then
+ 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
+import sys
+], [dnl
+ sys.exit(sys.exec_prefix)
+])])
+ AC_LANG_POP(Python)[]dnl
+fi
+])
+AC_SUBST([PYTHON_EXEC_PREFIX], [$pc_cv_python_exec_prefix])])
+
+
+# PC_PYTHON_CHECK_INCLUDES
+# ------------------------
+# Find the Python header file include flags (ie
+# '-I/usr/include/python')
+AC_DEFUN([PC_PYTHON_CHECK_INCLUDES],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the headers location with python-config otherwise guess
+AC_CACHE_CHECK([for Python includes], [pc_cv_python_includes],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS,
+ PYTHON_ABI_FLAGS,)"
+fi
+])
+AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
+
+
+# PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+# -----------------------
+# Check for the presence and usability of Python.h
+AC_DEFUN([PC_PYTHON_CHECK_HEADERS],
+[AC_REQUIRE([PC_PYTHON_CHECK_INCLUDES])[]dnl
+pc_cflags_store=$CPPFLAGS
+CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
+AC_CHECK_HEADER([Python.h], [$1], [$2])
+CPPFLAGS=$pc_cflags_store
+])
+
+
+# PC_PYTHON_CHECK_LIBS
+# --------------------
+# Find the Python lib flags (ie '-lpython')
+AC_DEFUN([PC_PYTHON_CHECK_LIBS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the lib flags with python-config otherwise guess
+AC_CACHE_CHECK([for Python libs], [pc_cv_python_libs],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)"
+fi
+])
+AC_SUBST([PYTHON_LIBS], [$pc_cv_python_libs])])
+
+
+# PC_PYTHON_TEST_LIBS(LIBRARY-FUNCTION, [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
+# -------------------
+# Verify that the Python libs can be loaded
+AC_DEFUN([PC_PYTHON_TEST_LIBS],
+[AC_REQUIRE([PC_PYTHON_CHECK_LIBS])[]dnl
+pc_libflags_store=$LIBS
+for lflag in $PYTHON_LIBS; do
+ case $lflag in
+ -lpython*@:}@
+ LIBS="$LIBS $lflag"
+ pc_libpython=`echo $lflag | sed -e 's/^-l//'`
+ ;;
+ *@:}@;;
+ esac
+done
+AC_CHECK_LIB([$pc_libpython], [$1], [$2], [$3])])
+
+
+# PC_PYTHON_CHECK_CFLAGS
+# ----------------------
+# Find the Python CFLAGS
+AC_DEFUN([PC_PYTHON_CHECK_CFLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the CFLAGS with python-config otherwise give up
+AC_CACHE_CHECK([for Python CFLAGS], [pc_cv_python_cflags],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_cflags=
+fi
+])
+AC_SUBST([PYTHON_CFLAGS], [$pc_cv_python_cflags])])
+
+
+# PC_PYTHON_CHECK_LDFLAGS
+# -----------------------
+# Find the Python LDFLAGS
+AC_DEFUN([PC_PYTHON_CHECK_LDFLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the LDFLAGS with python-config otherwise give up
+AC_CACHE_CHECK([for Python LDFLAGS], [pc_cv_python_ldflags],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_ldflags=
+fi
+])
+AC_SUBST([PYTHON_LDFLAGS], [$pc_cv_python_ldflags])])
+
+
+# PC_PYTHON_CHECK_EXTENSION_SUFFIX
+# --------------------------------
+# Find the Python extension suffix (i.e. '.cpython-32.so')
+AC_DEFUN([PC_PYTHON_CHECK_EXTENSION_SUFFIX],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the suffix with python-config otherwise give up
+AC_CACHE_CHECK([for Python extension suffix], [pc_cv_python_extension_suffix],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_extension_suffix=
+fi
+])
+AC_SUBST([PYTHON_EXTENSION_SUFFIX], [$pc_cv_python_extension_suffix])])
+
+
+# PC_PYTHON_CHECK_ABI_FLAGS
+# -------------------------
+# Find the Python ABI flags
+AC_DEFUN([PC_PYTHON_CHECK_ABI_FLAGS],
+[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
+dnl Try to find the ABI flags with python-config otherwise give up
+AC_CACHE_CHECK([for Python ABI flags], [pc_cv_python_abi_flags],
+[if test -x "$PYTHON_CONFIG"; then
+ pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>&AS_MESSAGE_LOG_FD`
+else
+ pc_cv_python_abi_flags=
+fi
+])
+AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
+
+
+# PC_PYTHON_CHECK_PLATFORM
+# ------------------------
+# 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
+dnl Get the platform from within Python (sys.platform)
+AC_CACHE_CHECK([for Python platform],
+ [pc_cv_python_platform],
+ [AC_LANG_PUSH(Python)[]dnl
+ AC_LANG_CONFTEST([
+ AC_LANG_PROGRAM([dnl
+import sys
+], [dnl
+ sys.stdout.write(sys.platform)
+])])
+ pc_cv_python_platform=`$PYTHON conftest.py`
+ AC_LANG_POP(Python)[]dnl
+ ])
+AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
+])
+
+
+# PC_PYTHON_CHECK_SITE_DIR
+# ---------------------
+# 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_CACHE_CHECK([for Python site-packages directory],
+ [pc_cv_python_site_dir],
+ [AC_LANG_PUSH(Python)[]dnl
+ if test "x$prefix" = xNONE
+ then
+ pc_py_prefix=$ac_default_prefix
+ else
+ pc_py_prefix=$prefix
+ fi
+ AC_LANG_CONFTEST([
+ AC_LANG_PROGRAM([dnl
+import sys
+from platform import python_implementation
+# sysconfig in CPython 2.7 doesn't work in virtualenv
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+ import sysconfig
+except:
+ can_use_sysconfig = False
+else:
+ can_use_sysconfig = True
+if can_use_sysconfig:
+ if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
+ can_use_sysconfig = False
+if not can_use_sysconfig:
+ from distutils import sysconfig
+ sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py_prefix')
+else:
+ sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
+], [dnl
+ sys.stdout.write(sitedir)
+])])
+ pc_cv_python_site_dir=`$PYTHON conftest.py`
+ AC_LANG_POP(Python)[]dnl
+ case $pc_cv_python_site_dir in
+ $pc_py_prefix*)
+ pc__strip_prefix=`echo "$pc_py_prefix" | sed 's|.|.|g'`
+ pc_cv_python_site_dir=`echo "$pc_cv_python_site_dir" | sed "s,^$pc__strip_prefix/,,"`
+ ;;
+ *)
+ case $pc_py_prefix in
+ /usr|/System*) ;;
+ *)
+ pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
+ ;;
+ esac
+ ;;
+ esac
+ ])
+AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SITE_DIR
+
+# PC_PYTHON_SITE_PACKAGE_DIR
+# --------------------------
+# $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])])
+
+
+# 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_CACHE_CHECK([for Python extension module directory],
+ [pc_cv_python_exec_dir],
+ [AC_LANG_PUSH(Python)[]dnl
+ if test "x$pc_cv_python_exec_prefix" = xNONE
+ then
+ pc_py_exec_prefix=$pc_cv_python_prefix
+ else
+ pc_py_exec_prefix=$pc_cv_python_exec_prefix
+ fi
+ AC_LANG_CONFTEST([
+ AC_LANG_PROGRAM([dnl
+import sys
+from platform import python_implementation
+# sysconfig in CPython 2.7 doesn't work in virtualenv
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+ import sysconfig
+except:
+ can_use_sysconfig = False
+else:
+ can_use_sysconfig = True
+if can_use_sysconfig:
+ if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
+ can_use_sysconfig = False
+if not can_use_sysconfig:
+ from distutils import sysconfig
+ sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py__exec_prefix')
+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`
+ AC_LANG_POP(Python)[]dnl
+ case $pc_cv_python_exec_dir in
+ $pc_py_exec_prefix*)
+ pc__strip_prefix=`echo "$pc_py_exec_prefix" | sed 's|.|.|g'`
+ pc_cv_python_exec_dir=`echo "$pc_cv_python_exec_dir" | sed "s,^$pc__strip_prefix/,,"`
+ ;;
+ *)
+ case $pc_py_exec_prefix in
+ /usr|/System*) ;;
+ *)
+ pc_cv_python_exec_dir=lib/python$PYTHON_VERSION/site-packages
+ ;;
+ esac
+ ;;
+ esac
+ ])
+AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CHECK_EXEC_LIB_DIR
+
+
+# PC_PYTHON_EXEC_PACKAGE_DIR
+# --------------------------
+# $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])])
+
+
+## -------------------------------------------- ##
+## 4. Looking for specific libs & functionality ##
+## -------------------------------------------- ##
+
+
+# PC_PYTHON_CHECK_MODULE(LIBRARY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ----------------------------------------------------------------------
+# Macro for checking if a Python library is installed
+AC_DEFUN([PC_PYTHON_CHECK_MODULE],
+[AC_REQUIRE([PC_INIT])[]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],
+ [AC_LANG_PUSH(Python)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+import sys
+try:
+ import $1
+except:
+ sys.exit(1)
+else:
+ sys.exit(0)
+], [])],
+ [[pc_cv_python_module_]pc_python_safe_mod="yes"],
+ [[pc_cv_python_module_]pc_python_safe_mod="no"])
+ AC_LANG_POP(Python)[]dnl
+ ])
+AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
+])# PC_PYTHON_CHECK_MODULE
+
+
+# PC_PYTHON_CHECK_FUNC([LIBRARY], FUNCTION, ARGS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------------------
+# 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
+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]],
+ [AC_LANG_PUSH(Python)[]dnl
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+import sys
+m4_ifnblank([$1], [dnl
+try:
+ import $1
+except:
+ sys.exit(1)
+], [])],
+[
+m4_ifnblank([$1], [
+ try:
+ $1.$2($3)], [
+ try:
+ $2($3)])
+ except:
+ sys.exit(1)
+ else:
+ sys.exit(0)
+])],
+ [[pc_cv_python_func_]pc_python_safe_mod[_$2]="yes"],
+ [[pc_cv_python_func_]pc_python_safe_mod[_$2]="no"])
+ AC_LANG_POP(Python)[]dnl
+ ])
+AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
+])# PC_PYTHON_CHECK_FUNC