Skip to content
Snippets Groups Projects
Commit ef2e40175711 authored by David Seifert's avatar David Seifert
Browse files

Use AM_PATH_PYTHON/PKG_CHECK_MODULES for python bindings

* `AM_PATH_PYTHON` is a much more common idiom for building
  and installing python modules than writing your own.
* It also makes cross-compiling the python bindings possible.
  Previously the `PYTHON_CFLAGS`/`PYTHON_LIBS` would have been
  based on the `--build` python and not the `--host` python.
  By using `pkg-config`, we can always redirect the python-X.Y.pc.
parent 194806361985
Branches
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@
libxslt/xsltconfig.h
ltmain.sh
missing
py-compile
python/*.pyc
python/gen_prog
python/libxslt-export.c
......
......@@ -26,6 +26,4 @@
gcc:python3:
extends: .test
only:
- schedules
variables:
......@@ -31,2 +29,3 @@
variables:
CFLAGS: "-O2"
PYTHON: "/usr/bin/python3"
......@@ -32,6 +31,4 @@
PYTHON: "/usr/bin/python3"
CONFIG: "--with-python=/usr/bin/python3"
CFLAGS: "-O2"
clang:asan:
extends: .test
......
SUBDIRS = \
libxslt \
libexslt \
xsltproc \
doc \
$(PYTHON_SUBDIR) \
tests
SUBDIRS = libxslt libexslt xsltproc doc tests
if WITH_PYTHON
SUBDIRS += python
endif
DIST_SUBDIRS = libxslt libexslt xsltproc python doc tests
......@@ -50,7 +47,9 @@
@echo '## Running the regression test suite'
@(cd tests ; $(MAKE) -s tests)
@(cd xsltproc ; $(MAKE) -s tests)
@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; $(MAKE) -s tests ; fi)
if WITH_PYTHON
@cd python && $(MAKE) tests
endif
valgrind:
@echo '## Running the regression tests under Valgrind'
......
......@@ -186,9 +186,4 @@
dnl check for python
dnl
PYTHON_VERSION=
PYTHON_INCLUDES=
PYTHON_SITE_PACKAGES=
PYTHON_TESTS=
pythondir=
AC_ARG_WITH(python,
......@@ -194,113 +189,11 @@
AC_ARG_WITH(python,
[ --with-python[[=DIR]] build Python bindings if found])
AC_ARG_WITH(python_install_dir,
[ --with-python-install-dir=DIR
install Python bindings in DIR])
if test "$with_python" != "no" ; then
if test -x "$with_python/bin/python"
then
echo Found python in $with_python/bin/python
PYTHON="$with_python/bin/python"
else
if test -x "$with_python/python.exe"
then
echo Found python in $with_python/python.exe
PYTHON="$with_python/python.exe"
else
if test -x "$with_python"
then
echo Found python in $with_python
PYTHON="$with_python"
else
if test -x "$PYTHON"
then
echo Found python in environment PYTHON=$PYTHON
with_python=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
else
AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5)
fi
fi
fi
fi
if test "$PYTHON" != ""
then
PYTHON_VERSION=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_version())"`
PYTHON_INCLUDES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_inc())"`
# does not work as it produce a /usr/lib/python path instead of/usr/lib64/python
#
# PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib())"`
echo Found Python version $PYTHON_VERSION
LIBXML2_PYTHON=`$PYTHON -c "import sys
try:
import libxml2
sys.stdout.write('1')
except:
sys.stdout.write('0')
"`
if test "$LIBXML2_PYTHON" = "1"
then
echo Found libxml2-python module
else
echo Warning: Missing libxml2-python
fi
fi
if test "$PYTHON_VERSION" != "" -a "$PYTHON_INCLUDES" = ""
then
if test -r $with_python/include/python$PYTHON_VERSION/Python.h
then
PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
else
if test -r $prefix/include/python$PYTHON_VERSION/Python.h
then
PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
else
if test -r /usr/include/python$PYTHON_VERSION/Python.h
then
PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
else
if test -r $with_python/include/Python.h
then
PYTHON_INCLUDES=$with_python/include
else
echo could not find python$PYTHON_VERSION/Python.h or $with_python/include/Python.h
fi
fi
fi
fi
fi
if test "$with_python_install_dir" != ""
then
PYTHON_SITE_PACKAGES="$with_python_install_dir"
fi
if test "$PYTHON_VERSION" != "" -a "$PYTHON_SITE_PACKAGES" = ""
then
if test -d $libdir/python$PYTHON_VERSION/site-packages
then
PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
else
if test -d $with_python/lib/site-packages
then
PYTHON_SITE_PACKAGES=$with_python/lib/site-packages
else
PYTHON_SITE_PACKAGES=$($PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(True,False,"${exec_prefix}"))')
fi
fi
fi
pythondir='$(PYTHON_SITE_PACKAGES)'
PYTHON_LIBS=`python$PYTHON_VERSION-config --ldflags`
else
PYTHON=
fi
AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
if test "$PYTHON_INCLUDES" != ""
then
PYTHON_SUBDIR=python
else
PYTHON_SUBDIR=
fi
AC_SUBST(pythondir)
AC_SUBST(PYTHON_SUBDIR)
AC_SUBST(PYTHON_LIBS)
[ --with-python build Python bindings (on)])
AS_IF([test "x$with_python" != "xno"], [
AM_PATH_PYTHON
PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
])
AM_CONDITIONAL([WITH_PYTHON], [test "x$with_python" != "xno"])
AC_ARG_WITH(crypto, [ --with-crypto Add crypto support to exslt (on)])
WITH_CRYPTO=0
......@@ -623,7 +516,6 @@
AC_SUBST(XSLTPROCDV)
AC_SUBST(PYTHONSODV)
AC_SUBST(XML_CONFIG)
AC_SUBST(LIBXML_LIBS)
AC_SUBST(LIBXML_CFLAGS)
......@@ -627,10 +519,6 @@
AC_SUBST(XML_CONFIG)
AC_SUBST(LIBXML_LIBS)
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(PYTHON)
AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_SITE_PACKAGES)
XSLT_LIBDIR='-L${libdir}'
XSLT_INCLUDEDIR='-I${includedir}'
......
......@@ -3,12 +3,6 @@
SUBDIRS = . tests
AM_CFLAGS = $(LIBXML_CFLAGS)
DOCS_DIR = $(datadir)/doc/libxslt-python-$(LIBXSLT_VERSION)
# libxsltclass.txt is generated
DOCS=
EXTRA_DIST = \
libxslt.c \
types.c \
......@@ -16,9 +10,6 @@
libxml_wrap.h \
libxslt_wrap.h \
libxsl.py \
libxslt-python-api.xml \
$(DOCS)
libxsltmod_la_LDFLAGS = -module -avoid-version
libxslt-python-api.xml
if WITH_PYTHON
......@@ -23,6 +14,3 @@
if WITH_PYTHON
mylibs = \
$(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la
......@@ -28,6 +16,4 @@
all-local: libxslt.py
python_LTLIBRARIES = libxsltmod.la
pyexec_LTLIBRARIES = libxsltmod.la
libxsltmod_la_CPPFLAGS = \
......@@ -32,5 +18,4 @@
libxsltmod_la_CPPFLAGS = \
-I$(PYTHON_INCLUDES) \
-I$(top_srcdir)/libxslt \
-I$(top_srcdir) \
......@@ -35,5 +20,6 @@
-I$(top_srcdir)/libxslt \
-I$(top_srcdir) \
-I../libexslt
-I../libexslt \
$(PYTHON_CFLAGS) $(LIBXML_CFLAGS)
libxsltmod_la_SOURCES = libxslt.c types.c
nodist_libxsltmod_la_SOURCES = libxslt-py.c
......@@ -38,7 +24,11 @@
libxsltmod_la_SOURCES = libxslt.c types.c
nodist_libxsltmod_la_SOURCES = libxslt-py.c
libxsltmod_la_LIBADD = $(mylibs) $(PYTHON_LIBS)
libxsltmod_la_LIBADD = \
$(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la \
$(PYTHON_LIBS) $(LIBXML_LIBS)
libxsltmod_la_LDFLAGS = -module -avoid-version
libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
cat $(srcdir)/libxsl.py libxsltclass.py > $@
......@@ -41,17 +31,8 @@
libxslt.py: $(srcdir)/libxsl.py libxsltclass.py
cat $(srcdir)/libxsl.py libxsltclass.py > $@
install-data-local:
$(MKDIR_P) $(DESTDIR)$(pythondir)
$(INSTALL) -m 0644 libxslt.py $(DESTDIR)$(pythondir)
$(MKDIR_P) $(DESTDIR)$(DOCS_DIR)
@(for doc in $(DOCS) ; \
do $(INSTALL) -m 0644 $(srcdir)/$$doc $(DESTDIR)$(DOCS_DIR) ; done)
uninstall-local:
rm -f $(DESTDIR)$(pythondir)/libxslt.py
rm -rf $(DESTDIR)$(DOCS_DIR)
python_PYTHON = libxslt.py
GENERATE = generator.py
API_DESC = $(top_srcdir)/doc/libxslt-api.xml $(srcdir)/libxslt-python-api.xml
......@@ -61,6 +42,9 @@
libxslt-py.h \
libxsltclass.txt
# Generated sources
all-local: libxslt.py
$(GENERATED): gen_prog
gen_prog: $(srcdir)/$(GENERATE) $(API_DESC)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment