From bsdkaffee@gmail.com  Thu Mar 10 13:37:45 2011
Return-Path: <bsdkaffee@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 174171065673;
	Thu, 10 Mar 2011 13:37:38 +0000 (UTC)
	(envelope-from bsdkaffee@gmail.com)
Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54])
	by mx1.freebsd.org (Postfix) with ESMTP id A43D78FC12;
	Thu, 10 Mar 2011 13:37:37 +0000 (UTC)
Received: by qwj8 with SMTP id 8so1308648qwj.13
        for <multiple recipients>; Thu, 10 Mar 2011 05:37:36 -0800 (PST)
Received: by 10.224.193.2 with SMTP id ds2mr1802247qab.156.1299764255683;
        Thu, 10 Mar 2011 05:37:35 -0800 (PST)
Received: from mocha.verizon.net (c-24-3-43-53.hsd1.oh.comcast.net [24.3.43.53])
        by mx.google.com with ESMTPS id s9sm2298949qco.12.2011.03.10.05.37.34
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 10 Mar 2011 05:37:35 -0800 (PST)
Message-Id: <4d78d41f.4969e50a.19a9.7cd8@mx.google.com>
Date: Thu, 10 Mar 2011 05:37:35 -0800 (PST)
From: Jason E. Hale <bsdkaffee@gmail.com>
Reply-To: Jason E. Hale <bsdkaffee@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: kde@FreeBSD.org
Subject: [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         155435
>Category:       ports
>Synopsis:       [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 10 13:40:10 UTC 2011
>Closed-Date:    Sun Mar 27 17:45:07 UTC 2011
>Last-Modified:  Sun Mar 27 17:45:07 UTC 2011
>Originator:     Jason E. Hale
>Release:        FreeBSD 8.2-RELEASE i386
>Organization:
none 
>Environment:
System: FreeBSD mocha.verizon.net 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Tue Feb 22 19:19:42 EST 2011 root@mocha.verizon.net:/usr/obj/usr/src/sys/MOCHA8 i386


	
>Description:
devel/kdebindings4-python-pykdeuic4 leaves Python ".pyo" files upon deinstall.
It uses the PYTHON_INSTALL macro defined by the PythonMacros.cmake module
installed by x11/kdelibs4 to install the .py and .pyc files but not the .pyo
files.

The .pyo files are generated when the Python module is used.

I have made a patch for PythonMacros.cmake to install the .pyo files and
added the .pyo files to the pkg-plist.

Patch should apply cleanly to the 4.5.5 ports and the 4.6.1 ports.
	
>How-To-Repeat:
Use attached diff.
	
>Fix:

	

--- 2011-03-10-kdelibs.diff begins here ---
diff -ruN kdelibs4.orig/files/patch-cmake_modules_PythonMacros.cmake kdelibs4/files/patch-cmake_modules_PythonMacros.cmake
--- kdelibs4.orig/files/patch-cmake_modules_PythonMacros.cmake	1969-12-31 19:00:00.000000000 -0500
+++ kdelibs4/files/patch-cmake_modules_PythonMacros.cmake	2011-03-10 07:47:25.000000000 -0500
@@ -0,0 +1,30 @@
+--- ./cmake/modules/PythonMacros.cmake.orig	2011-03-10 07:44:37.000000000 -0500
++++ ./cmake/modules/PythonMacros.cmake	2011-03-10 07:46:14.000000000 -0500
+@@ -35,6 +35,7 @@
+ 
+   SET(_bin_py ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filename})
+   SET(_bin_pyc ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filenamebase}.pyc)
++  SET(_bin_pyo ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filenamebase}.pyo)
+ 
+   FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_basepath})
+ 
+@@ -46,6 +47,7 @@
+       TARGET compile_python_files
+       COMMAND ${CMAKE_COMMAND} -E echo ${message}
+       COMMAND ${PYTHON_EXECUTABLE} ${_python_compile_py} ${_bin_py}
++      COMMAND ${PYTHON_EXECUTABLE} -O ${_python_compile_py} ${_bin_py}
+       DEPENDS ${_absfilename}
+     )
+   ELSE(_abs_bin_py STREQUAL ${_absfilename})
+@@ -54,9 +56,10 @@
+       COMMAND ${CMAKE_COMMAND} -E echo ${message} 
+       COMMAND ${CMAKE_COMMAND} -E copy ${_absfilename} ${_bin_py}
+       COMMAND ${PYTHON_EXECUTABLE} ${_python_compile_py} ${_bin_py}
++      COMMAND ${PYTHON_EXECUTABLE} -O ${_python_compile_py} ${_bin_py}
+       DEPENDS ${_absfilename}
+     )
+   ENDIF(_abs_bin_py STREQUAL ${_absfilename})
+ 
+-  INSTALL(FILES ${_bin_pyc} DESTINATION ${DESINATION_DIR})
++  INSTALL(FILES ${_bin_pyc} ${_bin_pyo} DESTINATION ${DESINATION_DIR})
+ ENDMACRO(PYTHON_INSTALL)
--- 2011-03-10-kdelibs.diff ends here ---

--- 2011-03-10-kdebindings4-python-pykdeuic4.diff begins here ---
diff -ruN kdebindings4-python-pykdeuic4.orig/pkg-plist kdebindings4-python-pykdeuic4/pkg-plist
--- kdebindings4-python-pykdeuic4.orig/pkg-plist	2011-03-10 07:36:47.000000000 -0500
+++ kdebindings4-python-pykdeuic4/pkg-plist	2011-03-10 07:37:47.000000000 -0500
@@ -1,8 +1,10 @@
 bin/pykdeuic4
 %%PYTHON_SITELIBDIR%%/PyQt4/uic/pykdeuic4.py
 %%PYTHON_SITELIBDIR%%/PyQt4/uic/pykdeuic4.pyc
+%%PYTHON_SITELIBDIR%%/PyQt4/uic/pykdeuic4.pyo
 %%PYTHON_SITELIBDIR%%/PyQt4/uic/widget-plugins/kde4.py
 %%PYTHON_SITELIBDIR%%/PyQt4/uic/widget-plugins/kde4.pyc
+%%PYTHON_SITELIBDIR%%/PyQt4/uic/widget-plugins/kde4.pyo
 @dirrmtry %%PYTHON_SITELIBDIR%%/PyQt4/uic/widget-plugins
 @dirrmtry %%PYTHON_SITELIBDIR%%/PyQt4/uic
 @dirrmtry %%PYTHON_SITELIBDIR%%/PyQt4
--- 2011-03-10-kdebindings4-python-pykdeuic4.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->kde 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Mar 10 13:40:32 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155435 

From: Raphael Kubo da Costa <kubito@gmail.com>
To: "Jason E. Hale" <bsdkaffee@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/155435: [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
Date: Thu, 10 Mar 2011 22:10:48 -0300

 Jason E.Hale <bsdkaffee@gmail.com> writes:
 
 >>Description:
 > The .pyo files are generated when the Python module is used.
 
 Can you elaborate?
 
 The PYTHON_INSTALL macro only seems to "byte-compile" the passed .py
 file into a .pyc file without passing "-O" to the python interpreter, so
 a ".pyo" should not have been generated at all. And even if it were,
 there seems to be no CMake command to install it.

From: "Jason E. Hale" <bsdkaffee@gmail.com>
To: Raphael Kubo da Costa <kubito@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: ports/155435: [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
Date: Fri, 11 Mar 2011 02:25:01 -0500

 On Thursday, March 10, 2011 20:10:48 Raphael Kubo da Costa wrote:
 > Jason E.Hale <bsdkaffee@gmail.com> writes:
 > >>Description:
 > > The .pyo files are generated when the Python module is used.
 > 
 > Can you elaborate?
 > 
 > The PYTHON_INSTALL macro only seems to "byte-compile" the passed .py
 > file into a .pyc file without passing "-O" to the python interpreter, so
 > a ".pyo" should not have been generated at all. And even if it were,
 > there seems to be no CMake command to install it.
 
 Right.  It works as it was intended; generate the .pyc file and install the 
 .py and .pyc files.  Somehow the .pyo files are being generated at runtime.  I 
 have not figured out what is causing that.  I only discovered it because I was 
 switching from Python 2.6.x to Python 2.7.x and was looking at all the 
 leftovers in the site-packages directory.
 
 I simply got to the bottom of why the .pyo files were not being installed in 
 the first place since just about every other Python application in the ports 
 tree installs them.  That is why I patched the PYTHON_INSTALL macro to also 
 install the optimized byte-compiled code.

From: Raphael Kubo da Costa <kubito@gmail.com>
To: "Jason E. Hale" <bsdkaffee@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: ports/155435: [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
Date: Fri, 11 Mar 2011 11:18:11 -0300

 "Jason E. Hale" <bsdkaffee@gmail.com> writes:
 
 > Right.  It works as it was intended; generate the .pyc file and install the 
 > .py and .pyc files.  Somehow the .pyo files are being generated at runtime.  I 
 > have not figured out what is causing that.  I only discovered it because I was 
 > switching from Python 2.6.x to Python 2.7.x and was looking at all the 
 > leftovers in the site-packages directory.
 
 I suspect something might be wrong with the Python handling code in
 ports -- I also had a lot of *.pyo files in my 2.6 site-packages after
 the ports were upgraded to 2.7, and I had to manually remove them.
 
 > I simply got to the bottom of why the .pyo files were not being installed in 
 > the first place since just about every other Python application in the ports 
 > tree installs them.  That is why I patched the PYTHON_INSTALL macro to also 
 > install the optimized byte-compiled code.
 
 I see. Well, I'd rather have this kind of change discussed upstream. As
 for this specific problem, I don't think it's KDE's fault.

From: "Jason E. Hale" <bsdkaffee@gmail.com>
To: Raphael Kubo da Costa <kubito@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: ports/155435: [PATCH] devel/kdebindings4-python-pykdeuic4 leaves .pyo files after deinstall
Date: Mon, 14 Mar 2011 17:31:06 -0400

 On Friday, March 11, 2011 09:18:11 Raphael Kubo da Costa wrote:
 > I suspect something might be wrong with the Python handling code in
 > ports -- I also had a lot of *.pyo files in my 2.6 site-packages after
 > the ports were upgraded to 2.7, and I had to manually remove them.
 > 
 There were only a few ports that left .pyo files on my system and I followed 
 up on each one: astro/gpsd, print/system-config-printer, and 
 devel/kdebindings4-python-pykdeuic4.  I'm sure there are more ports with the 
 same problem.
 
 The problem is that if Python is run with -O as root, any modules that are 
 imported will be byte-compiled with the .pyo extension.
 
 For example, if you do something like:
 # python -O
 >>> import PyQt4.uic.pykdeuic4
 
 The .pyo file will be created for ${PYTHON_SITELIBDIR}/PyQt4/uic/pykdeuic4.py
 
 > I see. Well, I'd rather have this kind of change discussed upstream. As
 > for this specific problem, I don't think it's KDE's fault.
 >
 It may be the way the KDE developers chose to handle Python files, but it 
 seems that the way almost all FreeBSD Python ports handle the issue is to just 
 install both the .pyc and the .pyo files.  If there is a chance that the file 
 could be created at some point I think we should just install it in the first 
 place.
 
 I also realized that the pkg-plist for devel/kdebindings4-python-pykde4 would 
 also be affected if my patch for PythonMacros.cmake were to be applied.
State-Changed-From-To: open->analyzed 
State-Changed-By: avilla 
State-Changed-When: Mon Mar 14 22:02:28 UTC 2011 
State-Changed-Why:  
i got the point. and yes, more ports require an updated plist. i will take care of this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155435 
State-Changed-From-To: analyzed->patched 
State-Changed-By: avilla 
State-Changed-When: Mon Mar 14 23:02:33 UTC 2011 
State-Changed-Why:  
committed to test repository. it will be in kde 4.6.1 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155435 
State-Changed-From-To: patched->closed 
State-Changed-By: avilla 
State-Changed-When: Sun Mar 27 17:45:06 UTC 2011 
State-Changed-Why:  
committed with the latest kde patchset. thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155435 
>Unformatted:
