From dc3e0ae6e0a1a8941de2fabb4db5692b0b63d2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Fri, 15 Jul 2005 16:38:59 +0000 Subject: [PATCH] add python support to configure git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10221 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 5 ++ config/ChangeLog | 4 ++ config/py-compile | 146 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 4 ++ lib/ChangeLog | 5 ++ lib/Makefile.am | 23 +------ lib/lyx2lyx/.cvsignore | 2 + lib/lyx2lyx/ChangeLog | 5 ++ lib/lyx2lyx/Makefile.am | 23 +++++++ 9 files changed, 195 insertions(+), 22 deletions(-) create mode 100755 config/py-compile create mode 100644 lib/lyx2lyx/Makefile.am diff --git a/ChangeLog b/ChangeLog index 5448a3666e..219c0b78d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-07-15 José Matos + + * configure.ac: Add support for python, and add Makefile to + lyx2lyx. + 2005-07-14 Angus Leeming * Makefile.am (EXTRA_DIST): add the new README and INSTALL files diff --git a/config/ChangeLog b/config/ChangeLog index f2ce9f3d8a..c091be78f4 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,7 @@ +2005-07-15 José Matos + + * py-compile: new file to byte-compile python scripts. + 2005-07-15 * lyxinclude.m4 (lyx_pch_comp): add profiling switch diff --git a/config/py-compile b/config/py-compile new file mode 100755 index 0000000000..ca2a05cc4a --- /dev/null +++ b/config/py-compile @@ -0,0 +1,146 @@ +#!/bin/sh +# py-compile - Compile a Python program + +scriptversion=2005-02-02.22 + +# Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. + +# 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 2, 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. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +if [ -z "$PYTHON" ]; then + PYTHON=python +fi + +basedir= +destdir= +files= +while test $# -ne 0; do + case "$1" in + --basedir) + basedir=$2 + if test -z "$basedir"; then + echo "$0: Missing argument to --basedir." 1>&2 + exit 1 + fi + shift + ;; + --destdir) + destdir=$2 + if test -z "$destdir"; then + echo "$0: Missing argument to --destdir." 1>&2 + exit 1 + fi + shift + ;; + -h|--h*) + cat <<\EOF +Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..." + +Byte compile some python scripts FILES. Use --destdir to specify any +leading directory path to the FILES that you don't want to include in the +byte compiled file. Specify --basedir for any additional path information you +do want to be shown in the byte compiled file. + +Example: + py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py + +Report bugs to . +EOF + exit $? + ;; + -v|--v*) + echo "py-compile $scriptversion" + exit $? + ;; + *) + files="$files $1" + ;; + esac + shift +done + +if test -z "$files"; then + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 +fi + +# if basedir was given, then it should be prepended to filenames before +# byte compilation. +if [ -z "$basedir" ]; then + pathtrans="path = file" +else + pathtrans="path = os.path.join('$basedir', file)" +fi + +# if destdir was given, then it needs to be prepended to the filename to +# byte compile but not go into the compiled file. +if [ -z "$destdir" ]; then + filetrans="filepath = path" +else + filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)" +fi + +$PYTHON -c " +import sys, os, string, py_compile + +files = '''$files''' + +print 'Byte-compiling python modules...' +for file in string.split(files): + $pathtrans + $filetrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + print file, + sys.stdout.flush() + py_compile.compile(filepath, filepath + 'c', path) +print" || exit $? + +# this will fail for python < 1.5, but that doesn't matter ... +$PYTHON -O -c " +import sys, os, string, py_compile + +files = '''$files''' +print 'Byte-compiling python modules (optimized versions) ...' +for file in string.split(files): + $pathtrans + $filetrans + if not os.path.exists(filepath) or not (len(filepath) >= 3 + and filepath[-3:] == '.py'): + continue + print file, + sys.stdout.flush() + py_compile.compile(filepath, filepath + 'o', path) +print" 2>/dev/null || : + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/configure.ac b/configure.ac index d0a64ccdb0..8e3de3d27a 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,9 @@ if test "x$KPSEWHICH" = xkpsewhich ; then fi AC_CHECK_PROGS(M4, gm4 gnum4 m4, m4) +# Check for installed python +AM_PATH_PYTHON(1.5.2,, :) + # Work around a problem in automake 1.4: when invoking install-strip, # INSTALL_PROGRAM is changed to 'install -s', and since # INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0 @@ -410,6 +413,7 @@ AC_CONFIG_FILES([Makefile m4/Makefile \ development/lyx.spec \ lib/Makefile \ lib/doc/Makefile \ + lib/lyx2lyx/Makefile \ intl/Makefile \ po/Makefile.in \ sourcedoc/Doxyfile \ diff --git a/lib/ChangeLog b/lib/ChangeLog index 4693c1cd3e..772242585d 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2005-07-15 José Matos + + * Makefile.am: remove lyx2lyx references, place it only as a + subdirectory. + 2005-07-15 Jean-Marc Lasgouttes * configure.m4: typo. diff --git a/lib/Makefile.am b/lib/Makefile.am index 92551f0bf7..1dc28e1782 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,7 +2,7 @@ include $(top_srcdir)/config/common.am DISTCLEANFILES += texput.log textclass.lst packages.lst lyxrc.defaults -SUBDIRS = doc reLyX +SUBDIRS = doc reLyX lyx2lyx EXTRA_DIST = \ configure.m4 \ @@ -833,26 +833,6 @@ dist_layouts_DATA =\ layouts/g-brief2.layout \ layouts/svglobal.layout -lyx2lyxdir = $(pkgdatadir)/lyx2lyx -# We cannot use dist_lyx2lyx_SCRIPTS for lyx2lyx, since a possible -# version-suffix would get appended to the names. So we use dist_scripts_DATA -# and chmod manually in install-data-hook. -dist_lyx2lyx_DATA = \ - lyx2lyx/lyx2lyx \ - lyx2lyx/parser_tools.py \ - lyx2lyx/LyX.py \ - lyx2lyx/lyx_0_12.py \ - lyx2lyx/lyx_1_0_0.py \ - lyx2lyx/lyx_1_0_1.py \ - lyx2lyx/lyx_1_1_4.py \ - lyx2lyx/lyx_1_1_5.py \ - lyx2lyx/lyx_1_1_6.py \ - lyx2lyx/lyx_1_1_6fix3.py \ - lyx2lyx/lyx_1_2.py \ - lyx2lyx/lyx_1_3.py \ - lyx2lyx/lyx_1_4.py \ - lyx2lyx/profiling.py - scriptsdir = $(pkgdatadir)/scripts # We cannot use dist_scripts_SCRIPTS, since a possible version-suffix would # get appended to the names. So we use dist_scripts_DATA and chmod manually @@ -941,7 +921,6 @@ install-data-local: install-xfonts uninstall-local: uninstall-xfonts install-data-hook: - $(CHMOD) 755 $(DESTDIR)$(pkgdatadir)/lyx2lyx/lyx2lyx $(CHMOD) 755 $(DESTDIR)$(pkgdatadir)/configure for i in $(dist_scripts_DATA); do \ $(CHMOD) 755 $(DESTDIR)$(pkgdatadir)/$$i; \ diff --git a/lib/lyx2lyx/.cvsignore b/lib/lyx2lyx/.cvsignore index c57ea56950..0e1d4d571b 100644 --- a/lib/lyx2lyx/.cvsignore +++ b/lib/lyx2lyx/.cvsignore @@ -1,3 +1,5 @@ *.pyc *.prof lyx2lyxc +Makefile +Makefile.in diff --git a/lib/lyx2lyx/ChangeLog b/lib/lyx2lyx/ChangeLog index 88b19011c0..7c63a1b3df 100644 --- a/lib/lyx2lyx/ChangeLog +++ b/lib/lyx2lyx/ChangeLog @@ -1,3 +1,8 @@ +2005-07-15 José Matos + + * Makefile.am: new file for correct dealing with python scripts. + * .cvsignore: ignore Makefile(.in) files. + 2005-07-12 José Matos * lyx_1_4.py (add_to_preamble): Make it more robust. diff --git a/lib/lyx2lyx/Makefile.am b/lib/lyx2lyx/Makefile.am new file mode 100644 index 0000000000..270d498646 --- /dev/null +++ b/lib/lyx2lyx/Makefile.am @@ -0,0 +1,23 @@ +include $(top_srcdir)/config/common.am + +CLEANFILES += *.pyc *.pyo + +lyx2lyxdir = $(pkgdatadir)/lyx2lyx +# We cannot use dist_lyx2lyx_SCRIPTS for lyx2lyx, since a possible +# version-suffix would get appended to the names. So we use dist_scripts_DATA +# and chmod manually in install-data-hook. +dist_lyx2lyx_PYTHON = \ + lyx2lyx \ + parser_tools.py \ + LyX.py \ + lyx_0_12.py \ + lyx_1_0_0.py \ + lyx_1_0_1.py \ + lyx_1_1_4.py \ + lyx_1_1_5.py \ + lyx_1_1_6.py \ + lyx_1_1_6fix3.py \ + lyx_1_2.py \ + lyx_1_3.py \ + lyx_1_4.py \ + profiling.py