20632171 Mailman should publish its .pyc files
authorJohn Beck <John.Beck@Oracle.COM>
Mon, 02 Mar 2015 16:15:04 -0800
changeset 3898 acd7f120a52a
parent 3897 cd126ba3fdda
child 3899 aa25d29e7836
20632171 Mailman should publish its .pyc files
components/mailman/Makefile
components/mailman/mailman.p5m
transforms/autopyc
--- a/components/mailman/Makefile	Tue Mar 03 11:01:06 2015 -0800
+++ b/components/mailman/Makefile	Mon Mar 02 16:15:04 2015 -0800
@@ -53,7 +53,14 @@
 
 ASLR_MODE = $(ASLR_ENABLE)
 
-# common targets
+# Copy generated file to proto area.  Then py-compile several files that are
+# used as modules in a devious way.
+COMPONENT_POST_INSTALL_ACTION=	\
+	($(CP) $(BUILD_DIR_64)/Mailman/Defaults.py \
+		$(PROTOUSRLIBDIR)/mailman/Mailman/ ; \
+	 $(PYTHON.2.7) -m py_compile $(PROTOUSRLIBDIR)/mailman/*/paths.py \
+		$(PROTOUSRLIBDIR)/mailman/Mailman/Defaults.py)
+
 configure:	$(CONFIGURE_64)
 
 build:		$(BUILD_64)
@@ -64,7 +71,6 @@
 
 PKG_PROTO_DIRS +=	$(COMPONENT_DIR)/files
 
-
 REQUIRED_PACKAGES += library/python/dnspython-27
 REQUIRED_PACKAGES += runtime/python-27
 REQUIRED_PACKAGES += shell/ksh93
--- a/components/mailman/mailman.p5m	Tue Mar 03 11:01:06 2015 -0800
+++ b/components/mailman/mailman.p5m	Mon Mar 02 16:15:04 2015 -0800
@@ -25,6 +25,19 @@
 
 <transform file path=usr/lib/mailman/tests/.* -> \
     default facet.optional.test true>
+# Exception to the exception below: paths.py instances.  These are modules
+# despite not looking like them.
+<transform file path=usr/lib/mailman/.*/paths\.py$ -> default \
+    pkg.tmp.pyversion 2.X>
+# Exception to the "Generate ..." rule below: certain sub-directories.
+<transform file path=usr/lib/mailman/(bin|cron|scripts|tests)/.*\.py$ -> \
+    default pkg.tmp.pyversion none>
+# Generate Python 2.x style .pyc files for all .py files.  Note that here
+# (and above) we set pkg.tmp.pyversion to "2.x" or "none" instead of the usual
+# setting of pkg.tmp.autopyc to "true" or "false" because the autopyc transform
+# file only deals with stuff under usr/lib/python[23].*; 20632788 has been
+# filed to clean this up.
+<transform file path=usr/lib/mailman/.*\.py$ -> default pkg.tmp.pyversion 2.X>
 <transform file \
     path=usr/lib/mailman/(messages|templates)/([^/]+)(\..+){0,1}(/.+){0,1}/.* \
     -> default facet.locale.%<\2> true>
@@ -59,6 +72,8 @@
 file mailman.conf path=etc/apache2/2.4/samples-conf.d/mailman.conf
 file usr/lib/mailman/Mailman/mm_cfg.py path=etc/mailman/mm_cfg.py \
     owner=mailman group=mailman mode=0644 overlay=allow preserve=true
+file usr/lib/mailman/Mailman/mm_cfg.pyc path=etc/mailman/mm_cfg.pyc \
+    owner=mailman group=mailman mode=0644 overlay=allow preserve=true
 file files/mailman.auth_attr path=etc/security/auth_attr.d/mailman group=sys
 file files/mailman.exec_attr path=etc/security/exec_attr.d/mailman group=sys
 file files/mailman.prof_attr path=etc/security/prof_attr.d/mailman group=sys
@@ -123,7 +138,7 @@
 file path=usr/lib/mailman/Mailman/Commands/cmd_subscribe.py
 file path=usr/lib/mailman/Mailman/Commands/cmd_unsubscribe.py
 file path=usr/lib/mailman/Mailman/Commands/cmd_who.py
-file $(MACH64)/Mailman/Defaults.py path=usr/lib/mailman/Mailman/Defaults.py
+file path=usr/lib/mailman/Mailman/Defaults.py
 file path=usr/lib/mailman/Mailman/Deliverer.py
 file path=usr/lib/mailman/Mailman/Digester.py
 file path=usr/lib/mailman/Mailman/Errors.py
@@ -216,6 +231,8 @@
 link path=usr/lib/mailman/Mailman/mm_cfg.py \
     target=../../../../etc/mailman/mm_cfg.py
 file path=usr/lib/mailman/Mailman/mm_cfg.py.dist
+link path=usr/lib/mailman/Mailman/mm_cfg.pyc \
+    target=../../../../etc/mailman/mm_cfg.pyc
 file path=usr/lib/mailman/Mailman/versions.py
 link path=usr/lib/mailman/archives/private \
     target=../../../../var/mailman/archives/private
--- a/transforms/autopyc	Tue Mar 03 11:01:06 2015 -0800
+++ b/transforms/autopyc	Mon Mar 02 16:15:04 2015 -0800
@@ -18,11 +18,16 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Don't bother specifying each .pyc file.  Allow individual actions to
 # override this by setting pkg.tmp.autopyc to false.
+# Note that prior to Python 3, the following covered all .py files.  But since
+# then only files under usr/lib/python[23].* are covered, and any components
+# shipping .py files elsewhere need to specify pkg.tmp.pyversion directly to
+# generate .pyc files.  But that variable really should be private to this
+# file. 20632788 has been filed to fix this.
 <transform file path=.*\.py$ -> default pkg.tmp.autopyc true>
 <transform file hardlink pkg.tmp.autopyc=true path=usr/lib/python2\.(.*)\.py$ -> default pkg.tmp.pyversion 2.X>
 <transform file hardlink pkg.tmp.autopyc=true path=usr/lib/python3\.(.*)/.*\.py$ -> default pkg.tmp.pyversion 3.%<1>>