Re: Proposal: 7.2b2 today

D'Arcy Cain <darcy@druid.net>

From: darcy@druid.net (D'Arcy J.M. Cain)
To: pgman@candle.pha.pa.us (Bruce Momjian)
Cc: scrappy@hub.org (Marc G. Fournier), pgsql-hackers@postgresql.org
Date: 2001-11-06T09:12:56Z
Lists: pgsql-hackers
Thus spake Bruce Momjian
> > Unless someone has something they are sitting on, I'd like to wrap up a
> > 7.2b2 this afternoon, and do a proper release announcement for it like
> > didn't happen for 7.2b1 ...
> 
> I have been working with Tom on some pgindent issues and have made
> slight improvements to the script.  Because we are early in beta and no
> one has outstanding patches, I would like to run it again and commit the
> changes.  It should improve variables defined as structs and alignment
> of include/catalog/*.h files.

I have a change I would like to discuss.  It doesn't change the code
base, only the build system.  The patches I would like to commit follow
this text.  The only thing it does is create a config option to bytecode
compile the Python modules.  It also cleans up the install in the Makefile
a little bit.

Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql/configure.in,v
retrieving revision 1.150
diff -u -r1.150 configure.in
--- configure.in	2001/10/25 13:02:01	1.150
+++ configure.in	2001/11/06 09:09:50
@@ -398,6 +398,18 @@
 AC_MSG_RESULT([$with_python])
 AC_SUBST(with_python)
 
+# If python is enabled (above), then optionally byte-compile the modules.
+AC_MSG_CHECKING([whether to byte-compile Python modules])
+if test "$with_python" = yes; then
+  PGAC_ARG_BOOL(with, python_compile, no,
+    [  --with-python-compile   byte-compile modules if Python is enabled])
+else
+  with_python_compile=no
+fi
+AC_MSG_RESULT([$with_python_compile])
+AC_SUBST([with_python_compile])
+
+
 #
 # Optionally build the Java/JDBC tools
 #
Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.140
diff -u -r1.140 Makefile.global.in
--- src/Makefile.global.in	2001/10/13 15:24:23	1.140
+++ src/Makefile.global.in	2001/11/06 09:09:54
@@ -123,6 +123,7 @@
 with_java	= @with_java@
 with_perl	= @with_perl@
 with_python	= @with_python@
+with_python_compile	= @with_python_compile@
 with_tcl	= @with_tcl@
 with_tk		= @with_tk@
 enable_odbc	= @enable_odbc@
Index: src/interfaces/python/GNUmakefile
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/python/GNUmakefile,v
retrieving revision 1.11
diff -u -r1.11 GNUmakefile
--- src/interfaces/python/GNUmakefile	2001/08/24 14:07:50	1.11
+++ src/interfaces/python/GNUmakefile	2001/11/06 09:10:00
@@ -19,10 +19,23 @@
 
 override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) $(python_includespec)
 
-all: all-lib
+PY_SCRIPTS = pg.py pgdb.py
+ifeq ($(with_python_compile), yes)
+PY_COMPILED_SCRIPTS = $(PY_SCRIPTS:%.py=%.pyc) $(PY_SCRIPTS:%.py=%.pyo)
+else
+PY_COMPILED_SCRIPTS =
+endif
 
+all: all-lib $(PY_COMPILED_SCRIPTS)
+
 all-lib: libpq-all
 
+%.pyc: %.py
+	python -c "import py_compile; py_compile.compile(\"$<\")"
+
+%.pyo: %.py
+	python -O -c "import py_compile; py_compile.compile(\"$<\")"
+
 .PHONY: libpq-all
 libpq-all:
 	$(MAKE) -C $(libpq_builddir) all
@@ -37,12 +50,11 @@
 	@if test -w $(DESTDIR)$(python_moduleexecdir) && test -w $(DESTDIR)$(python_moduledir); then \
 	  echo "$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(python_moduleexecdir)/_pgmodule$(DLSUFFIX)"; \
 	  $(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(python_moduleexecdir)/_pgmodule$(DLSUFFIX); \
-	\
-	  echo "$(INSTALL_DATA) $(srcdir)/pg.py $(DESTDIR)$(python_moduledir)/pg.py"; \
-	  $(INSTALL_DATA) $(srcdir)/pg.py $(DESTDIR)$(python_moduledir)/pg.py; \
 	\
-	  echo "$(INSTALL_DATA) $(srcdir)/pgdb.py $(DESTDIR)$(python_moduledir)/pgdb.py"; \
-	  $(INSTALL_DATA) $(srcdir)/pgdb.py $(DESTDIR)$(python_moduledir)/pgdb.py; \
+	  for i in $(PY_SCRIPTS) $(PY_COMPILED_SCRIPTS); do \
+		echo $(INSTALL_DATA) $$i $(python_moduledir); \
+		$(INSTALL_DATA) $$i $(python_moduledir); \
+	  done \
 	else \
 	  $(install-warning-msg); \
 	fi

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.