From: François Pinard Date: Thu, 6 Mar 2008 22:50:41 +0000 (-0500) Subject: Use distutils in tests/ X-Git-Tag: v3.7-beta2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=713036ccc6bbf7de16401c01a1212e1d9bc8bce8;p=recode Use distutils in tests/ --- diff --git a/ChangeLog b/ChangeLog index 0553a96..03a03ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * Makefile (get-po-files): New. + * configure.ac (AC_OUTPUT): Add tests/setup.py. + 2008-02-27 François Pinard To solve linker namespace pollution: diff --git a/configure b/configure index 806bdf6..c37f6ae 100755 --- a/configure +++ b/configure @@ -23989,7 +23989,7 @@ _ACEOF -ac_config_files="$ac_config_files Makefile cleaner.h contrib/Makefile doc/Makefile lib/Makefile libiconv/Makefile po/Makefile.in src/Makefile tests/Makefile" +ac_config_files="$ac_config_files Makefile cleaner.h contrib/Makefile doc/Makefile lib/Makefile libiconv/Makefile po/Makefile.in src/Makefile tests/Makefile tests/setup.py" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -24594,6 +24594,7 @@ do "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "tests/setup.py") CONFIG_FILES="$CONFIG_FILES tests/setup.py" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} diff --git a/configure.ac b/configure.ac index ebfba51..8d203a9 100644 --- a/configure.ac +++ b/configure.ac @@ -45,4 +45,5 @@ AH_BOTTOM([ ]) AC_OUTPUT(Makefile cleaner.h contrib/Makefile doc/Makefile lib/Makefile - libiconv/Makefile po/Makefile.in src/Makefile tests/Makefile) + libiconv/Makefile po/Makefile.in src/Makefile tests/Makefile + tests/setup.py) diff --git a/tests/ChangeLog b/tests/ChangeLog index 47059e6..44f3cf7 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2008-03-06 François Pinard + + Increase Recode.so portability, by depending on distutils: + * setup.py.in: New file. + * Makefile.am (Recode.so): Use it. + (all-local, Recode.o): Deleted. + Reported by Bruno Haible and Dagobert Michelsen. + 2008-03-05 François Pinard * Makefile.am (CLEANFILES): Added. diff --git a/tests/Makefile.am b/tests/Makefile.am index b3a5093..173a9b9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,21 +27,14 @@ EXTRA_DIST = NOTES Recode.c Recode.pyx pytest common.py $(SUITE) PYTHON = python -CLEANFILES = Recode.o Recode.so +CLEANFILES = Recode.so -all-local: Recode.so - -check-local: +check-local: Recode.so RECODE=../src/recode PYTHONPATH=.:$(srcdir) \ $(PYTHON) $(srcdir)/pytest $(srcdir)/t*.py -Recode.so: Recode.o - $(CC) -shared $< -lrecode `python-config --libs` -o $@ - -Recode.o: Recode.c - $(CC) -c -fPIC `python-config --cflags` \ - -I $(top_builddir) -I $(top_srcdir)/src $< +Recode.so: Recode.c setup.py + $(PYTHON) setup.py build Recode.c: Recode.pyx cd $(srcdir) && pyrexc Recode.pyx - diff --git a/tests/Makefile.in b/tests/Makefile.in index 4a138e2..7717166 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -51,7 +51,8 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = tests -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/setup.py.in ChangeLog ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc21.m4 \ @@ -65,7 +66,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = +CONFIG_CLEAN_FILES = setup.py SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -203,7 +204,7 @@ t40_utf7.py t40_utf8.py t50_methods.py t90_bigauto.py EXTRA_DIST = NOTES Recode.c Recode.pyx pytest common.py $(SUITE) PYTHON = python -CLEANFILES = Recode.o Recode.so +CLEANFILES = Recode.so all: all-am .SUFFIXES: @@ -236,6 +237,8 @@ $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +setup.py: $(top_builddir)/config.status $(srcdir)/setup.py.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo @@ -278,7 +281,7 @@ distdir: $(DISTFILES) check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-local check: check-am -all-am: Makefile all-local +all-am: Makefile installdirs: install: install-am install-exec: install-exec-am @@ -361,10 +364,10 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: all all-am all-local check check-am check-local clean \ - clean-generic clean-libtool distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ +.PHONY: all all-am check check-am check-local clean clean-generic \ + clean-libtool distclean distclean-generic distclean-libtool \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ @@ -374,18 +377,12 @@ uninstall-am: uninstall uninstall-am -all-local: Recode.so - -check-local: +check-local: Recode.so RECODE=../src/recode PYTHONPATH=.:$(srcdir) \ $(PYTHON) $(srcdir)/pytest $(srcdir)/t*.py -Recode.so: Recode.o - $(CC) -shared $< -lrecode `python-config --libs` -o $@ - -Recode.o: Recode.c - $(CC) -c -fPIC `python-config --cflags` \ - -I $(top_builddir) -I $(top_srcdir)/src $< +Recode.so: Recode.c setup.py + $(PYTHON) setup.py build Recode.c: Recode.pyx cd $(srcdir) && pyrexc Recode.pyx diff --git a/tests/setup.py.in b/tests/setup.py.in new file mode 100644 index 0000000..a844d2a --- /dev/null +++ b/tests/setup.py.in @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +from distutils.core import setup, Extension + +build = 'build' +srcdir = '@srcdir@' +top_builddir = '@top_builddir@' +top_srcdir = '@top_srcdir@' + +try: + + if srcdir != '.': + buffer = file(os.path.join(srcdir, 'Recode.c')).read() + file('Recode.c', 'w').write(buffer) + + setup(ext_modules=[ + Extension('Recode', ['Recode.c'], + include_dirs=[top_builddir, os.path.join(top_srcdir, 'src')], + libraries=['recode']) + ]) + +finally: + + if srcdir != '.': + if os.path.exists('Recode.c'): + os.remove('Recode.c') + +def extract_and_clean(directory): + for base in os.listdir(directory): + name = os.path.join(directory, base) + if base == 'Recode.so': + buffer = file(name, 'rb').read() + file('Recode.so', 'wb').write(buffer) + if os.path.isdir(name): + extract_and_clean(name) + else: + os.remove(name) + os.rmdir(directory) + +extract_and_clean(build)