Bug 171381 - [patch] finance/gnucash fails to generate and install .pyc/.pyo files
Summary: [patch] finance/gnucash fails to generate and install .pyc/.pyo files
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-gnome (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-06 14:40 UTC by John W. O'Brien
Modified: 2012-12-29 23:10 UTC (History)
0 users

See Also:


Attachments
file.diff (566 bytes, patch)
2012-09-06 14:40 UTC, John W. O'Brien
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John W. O'Brien 2012-09-06 14:40:13 UTC
When Python binding/support is enabled (PORT_OPTIONS+=PYTHON), the compiled Python bytecode (.pyc) and optimized bytecode (.pyo) files are not generated by the build target, nor installed by the install target. However, the packing list specifies them and therefore the package target expects them and fails as a result.

[/usr/ports]# svn info | egrep "URL|Revision"
URL: svn://svn0.us-east.freebsd.org/ports/head
Revision: 303631

[/usr/ports/finance/gnucash]# make showconfig
===> The following configuration options are available for gnucash-2.4.11_2:
     AQBANKING=on: AqBanking support (HBCI/OpenHBCI)
     DATABASE=on: Enable SQL database backends
     LOCALE_TAX=off: Enable localized tax categories
     OFX=on: OFX support
     PYTHON=on: Python binding/support
     WEBKIT=off: Use webkit instead of gtkhtml for the HTML engine
===> Use 'make config' to modify these settings

[/usr/ports/finance/gnucash]# make -V CC -V CXX -V CPP -V PYTHON_REL
clang
clang++
clang-cpp
273

[/usr/ports/finance/gnucash]# grep ".py" pkg-plist 
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/__init__.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/__init__.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/__init__.pyo
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/function_class.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/function_class.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/function_class.pyo
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_business.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_business.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_business.pyo
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core.pyo
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core_c.py
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core_c.pyc
%%PYTHON%%%%PYTHON_SITELIBDIR%%/gnucash/gnucash_core_c.pyo

Fix: The attached patch provides a quick and dirty solution by generating the compiled bytecode files in situ using a gnucash-provided in the post-install target. If this script were to fail, the installation would not complete cleanly (e.g. pkg_delete would be useless).

I expect that a better fix would be to patch, in an upstream-able fashion, ${WRKDIR}/gnucash-2.4.11/src/optional/python-bindings/Makefile.am to generate and install the bytecode files. This exceeds my abilities with autotools however and must be deferred to a more knowledgeable developer. I'd be happy to help if given suitable direction.

Patch attached with submission follows:
How-To-Repeat: (Output omitted)

Package creation fails:

[/usr/ports/finance/gnucash]# make package

Package deinstallation generates warnings due to missing files:

[/usr/ports/finance/gnucash]# make install
[/usr/ports/finance/gnucash]# make deinstall
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-09-06 14:40:32 UTC
Responsible Changed
From-To: freebsd-ports-bugs->gnome

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 John W. O'Brien 2012-09-07 03:59:28 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

OK, so I did some more sleuthing, and while I am still nowhere near
being the autotools ninja I think I would need to be to propose a
proper fix, I will share my findings in the hope that such a ninja is
listening.

My first stop of note was the automake manual where I learned that the
py-compile script, which is actually part of AM, is applied to
properly-identified Python files.

https://www.gnu.org/software/automake/manual/automake.html#Python

So how are those files marked? See lines 5-10:

http://svn.gnucash.org/trac/browser/gnucash/tags/2.4.11/src/optional/python-bindings/Makefile.am

That doesn't look like what the AM manual says. How did it get to be
that way? Here's the offending changeset in trunk...

http://svn.gnucash.org/trac/changeset/21905

... and the backport to the 2.4 series.

http://svn.gnucash.org/trac/changeset/22020

Following the breadcrumbs back to the source, we find the report of a
vague, unconfirmed problem with the patch that breaks the AM use of
py-compile.

https://bugzilla.gnome.org/show_bug.cgi?id=668196

The upshot is that any upstream-facing way to resolve this needs to
accommodate this upstream bug. However, "accommodate" may mean "show
why installing in different places is correct and not the cause of any
issues on those platforms," but that sounds excessively difficult.

In the mean time, I would offer an alternative patch, which merely
performs a local revert of r22020, but I can't figure out how to tell
ports that I want to regenerate the Makefile.in from the reverted
Makefile.am. I've tried several basic combinations of the
USE_AUTOTOOLS variable to no avail. If somebody gives me a gently push
in the right direction, I'll gladly prepare that new patch.

Regards,
John
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQSWMNAAoJEEdKvTwaez9wnGQH/2+LAPtnAYcSKBQlcM2BYRPu
IC2D2pboL9rFA7QF5z3vEhijohnVSgpgHZPEw8pHX8uDcbKQd3HmPk1T1Onk8OCz
uqUqQtGpv5NH6Ch8hOafR2BZXDc+zkBonAR/Xq5K8yuYfZvcIwE+azPhEiKyZJV4
eJCrUYmztW2A4BVbuxBKpMY+hDCK6OBkunKu9p+jTv5ptn6UDW8Y5T5MhED4Ig6i
0B4HBZKz7wMomyl1Xi6gXnLGnKImPdaLKWXeB6qSi8M2XYa6o1iGvppqx4388JRS
n0H4uFWh9oBhxhLRnAHYvSPB3oAFYNKBis+PlVX6144HCwpZxAQgwhJOcc7t08Y=
=YYU4
-----END PGP SIGNATURE-----
Comment 3 Jeremy Messenger freebsd_committer freebsd_triage 2012-12-29 23:00:46 UTC
State Changed
From-To: open->closed

You have found right place where the problem is. I recommend you to file a 
bug report over at gnucash place. I have committed a fix by using 
${PYTHON_LIBDIR}/compileall.py instead of py-compile one that was included 
in its package. Thanks!
Comment 4 dfilter service freebsd_committer freebsd_triage 2012-12-29 23:01:05 UTC
Author: mezz
Date: Sat Dec 29 23:00:38 2012
New Revision: 309640
URL: http://svnweb.freebsd.org/changeset/ports/309640

Log:
  Fix the generate of .pyc/pyo (Python bytecode), bump the PORTREVISION.
  
  PR:		ports/171381
  Submitted by:	"John W. O'Brien" <john@saltant.com>

Modified:
  head/finance/gnucash/Makefile

Modified: head/finance/gnucash/Makefile
==============================================================================
--- head/finance/gnucash/Makefile	Sat Dec 29 23:00:17 2012	(r309639)
+++ head/finance/gnucash/Makefile	Sat Dec 29 23:00:38 2012	(r309640)
@@ -3,7 +3,7 @@
 
 PORTNAME=	gnucash
 PORTVERSION=	2.4.11
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	finance gnome
 MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20%28stable%29/${PORTVERSION}
 
@@ -106,7 +106,7 @@ LIB_DEPENDS+=	webkitgtk-1.0:${PORTSDIR}/
 USE_GNOME+=	gtkhtml3
 .endif
 
-.if${PORT_OPTIONS:MPYTHON}
+.if ${PORT_OPTIONS:MPYTHON}
 CONFIGURE_ARGS+=--enable-python-bindings
 USE_PYTHON=	yes
 PLIST_SUB+=	PYTHON=""
@@ -115,6 +115,12 @@ PLIST_SUB+=	PYTHON="@comment "
 .endif
 
 post-install:
+.if ${PORT_OPTIONS:MPYTHON}
+	@${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
+		${PYTHON_SITELIBDIR:S|${LOCALBASE}|${PREFIX}|}/${PORTNAME}
+	@${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
+		${PYTHON_SITELIBDIR:S|${LOCALBASE}|${PREFIX}|}/${PORTNAME}
+.endif
 	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.mk>
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"