]> granicus.if.org Git - recode/commitdiff
Use distutils in tests/
authorFrançois Pinard <pinard@iro.umontreal.ca>
Thu, 6 Mar 2008 22:50:41 +0000 (17:50 -0500)
committerFrançois Pinard <pinard@iro.umontreal.ca>
Fri, 7 Mar 2008 14:59:14 +0000 (09:59 -0500)
ChangeLog
configure
configure.ac
tests/ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/setup.py.in [new file with mode: 0644]

index 0553a96954fe75e0fcd987a1527e27fb04aecb57..03a03ed1dea3959292e3f633da605084ecedd3f9 100644 (file)
--- 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  <pinard@iro.umontreal.ca>
 
        To solve linker namespace pollution:
index 806bdf6c29f161ac25125747c7b21af9a0d8bf52..c37f6ae2e701ced8db59d48e975ec44ec4ba8bbb 100755 (executable)
--- 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;}
index ebfba51e8ffa64f1d21c0dc1da9f6d5e1f36625b..8d203a9e7db74d4f5e8a20972e203ce9868262a0 100644 (file)
@@ -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)
index 47059e656b6a9fb79642b534702997927574c7d6..44f3cf7dee834a769bc5e3526e212d7254d38866 100644 (file)
@@ -1,3 +1,11 @@
+2008-03-06  François Pinard  <pinard@iro.umontreal.ca>
+
+       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  <pinard@iro.umontreal.ca>
 
        * Makefile.am (CLEANFILES): Added.
index b3a5093e55129318e7d65357b3cc58956a42b1fb..173a9b9081bf0553abbf9d6322134342dcad750d 100644 (file)
@@ -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
-
index 4a138e2b50de656da176255585c2076bd5dd1044..7717166cd7edcf421e2bba9e2157bc2149309378 100644 (file)
@@ -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 (file)
index 0000000..a844d2a
--- /dev/null
@@ -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)