From: Peter Johnson Date: Tue, 4 Apr 2006 07:51:42 +0000 (-0000) Subject: Be much smarter at checking for and running Pyrex. Pyrex is a Python module X-Git-Tag: v0.5.0rc2~2^2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b22db3f5cac96015a29449a968b1fcdb48d1fe93;p=yasm Be much smarter at checking for and running Pyrex. Pyrex is a Python module and the "pyrexc" command is just a wrapper, so instead of looking for "pyrexc" look for the module instead. * pyrex.m4: New macro to check Pyrex version. * m4/Makefile.inc: Add to dist. * configure.ac: Use macro to check for Pyrex >= 0.9.3. * python-yasm/Makefile.inc: Run Python directly instead of pyrexc wrapper. svn path=/trunk/yasm/; revision=1457 --- diff --git a/configure.ac b/configure.ac index 95d47b9a..f6011810 100644 --- a/configure.ac +++ b/configure.ac @@ -264,13 +264,11 @@ else if test -z "$PYTHON" ; then AC_MSG_WARN([Python not found]) else - AC_CHECK_PROGS(PYREX, pyrexc) - - if test -z "$PYREX" ; then - have_pyrex=no - else - have_pyrex=yes - fi + AC_MSG_CHECKING([for Pyrex >= 0.9.3]) + PYREX_CHECK_VERSION(0.9.3, [AC_MSG_RESULT(yes) + have_pyrex=yes], + [AC_MSG_RESULT(no) + have_pyrex=no]) AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no) diff --git a/m4/Makefile.inc b/m4/Makefile.inc index 3df185a9..4dac7a1c 100644 --- a/m4/Makefile.inc +++ b/m4/Makefile.inc @@ -27,3 +27,4 @@ EXTRA_DIST += m4/progtest.m4 EXTRA_DIST += m4/stdint_h.m4 EXTRA_DIST += m4/uintmax_t.m4 EXTRA_DIST += m4/pythonhead.m4 +EXTRA_DIST += m4/pyrex.m4 diff --git a/m4/pyrex.m4 b/m4/pyrex.m4 new file mode 100644 index 00000000..b6e5bd66 --- /dev/null +++ b/m4/pyrex.m4 @@ -0,0 +1,14 @@ +AC_DEFUN([PYREX_CHECK_VERSION], + [prog="import sys +from Pyrex.Compiler.Version import version +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +pyrexver = map(int, version.split('.')) + [[0, 0, 0]] +pyrexverhex = 0 +for i in xrange(0, 4): pyrexverhex = (pyrexverhex << 8) + pyrexver[[i]] +minver = map(int, '$1'.split('.')) + [[0, 0, 0]] +minverhex = 0 +for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] +sys.exit(pyrexverhex < minverhex)" + AS_IF([AM_RUN_LOG([$PYTHON -c "$prog"])], [$2], [$3])]) + diff --git a/tools/python-yasm/Makefile.inc b/tools/python-yasm/Makefile.inc index 3f0f8f43..128a68e0 100644 --- a/tools/python-yasm/Makefile.inc +++ b/tools/python-yasm/Makefile.inc @@ -14,7 +14,8 @@ EXTRA_DIST += tools/python-yasm/yasm.pyx EXTRA_DIST += $(PYBINDING_DEPS) yasm_python.c: $(srcdir)/tools/python-yasm/yasm.pyx $(PYBINDING_DEPS) - $(PYREX) -o $@ `test -f tools/python-yasm/yasm.pyx || echo '$(srcdir)/'`tools/python-yasm/yasm.pyx + $(PYTHON) -c "from Pyrex.Compiler.Main import main; main(command_line=1)" \ + -o $@ `test -f tools/python-yasm/yasm.pyx || echo '$(srcdir)/'`tools/python-yasm/yasm.pyx CLEANFILES += yasm_python.c