[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Suggestion: pylint



On Fri, 2005-06-17 at 13:19 +0100, Mark McLoughlin wrote: 
> Hi,
> 
> On Sat, 2005-04-23 at 04:29 +0000, Michael A. Peters wrote:
> 
> > I believe extras wants you to %ghost the *.pyo files in site-packages
> 
> 	The conclusion from this thread seems to be:
> 
>   https://www.redhat.com/archives/fedora-devel-list/2004-December/thread.html#00849
> 
> 	that
> 
I think it was more of an impasse.

>   1) This is just about disk space; the idea is that shipping .pyo 
>      files don't give you an appreciable startup speed win so we 
>      should we shouldn't package them
> 
.pyo's can also break python programs.  The "optimizations" include
things like removing docstrings which programs may depend upon to
function.

>   2) That %ghost-ing .pyo files is more trouble than its worth
> 
Is %{find_lang} more trouble than it's worth?  It similarly is just a
space savings.

> Thoughts?

1) Current Extras packages already adhere to this standard.

2) We must include the pyo's in the %files section either as %ghost or
as normal files otherwise they won't get removed from the system once
they are created.

3) It's not that hard to implement this in a spec file.  It's also not
that hard to implement a script to do it for you.

Attached is a script that takes a directory and generates a file list.
It can replace a common %files idiom such as:
  %files
  %{python_sitelib}/docutils
with:
  %install
  [..]
  %{find_pyfiles} %{python_sitelib}/docutils docutils

  %files -f docutils.pyfiles
  [..]

There are other solutions as well (something more like 
%find_lang, for instance, that scans the whole %buildroot for python
files and correctly lists those files and the directories they reside in
for instance.)

-Toshio

PS Second attachment is a patch which adds the find_pyfiles macro to
rpm/redhat/macros and adds this file to the rpm/redhat/macros/
directory.

Attachment: find-pyfiles.sh
Description: application/shellscript

--- ./usr/lib/rpm/redhat/macros.findpy	2005-06-17 23:31:00.000000000 -0400
+++ ./usr/lib/rpm/redhat/macros	2005-06-17 23:31:58.000000000 -0400
@@ -136,6 +136,8 @@
 
 %find_lang      /usr/lib/rpm/redhat/find-lang.sh %{buildroot}
 
+%find_pyfiles	/usr/lib/rpm/redhat/find-pyfiles.sh %{buildroot}
+
 #
 # use internal dep generator?
 %_use_internal_dependency_generator 1
--- ./usr/lib/rpm/redhat/find-pyfiles.sh.findpy	2005-06-18 00:14:23.000000000 -0400
+++ ./usr/lib/rpm/redhat/find-pyfiles.sh	2005-06-18 00:10:47.000000000 -0400
@@ -0,0 +1,56 @@
+#!/bin/sh
+# find-pyfiles - automagically generate list files in a directory with python
+# optimized (.pyo) files %ghosted.
+# for inclusion in an rpm spec file.
+
+# Created by Toshio Kuratomi 2005
+# Based on findlang, copyright (c) 1998 by W. L. Estes <wlestes uncg edu>
+
+#Redistribution and use of this software are hereby permitted for any
+#purpose as long as this notice and the above copyright notice remain
+#in tact and are included with any redistribution of this file or any
+#work based on this file.
+
+usage () {
+cat <<EOF
+
+Usage: $0 DESTDIR DIRECTORY_TO_ADD PREFIX
+
+where DESTDIR is the \$RPM_BUILD_ROOT.  DESTDIR gets sed'd out of the
+output list.
+DIRECTORY_TO_ADD is the directory under DESTDIR which will be added to
+the %files list.  All files within the directory except .pyo files
+will be added to the file list.  The .pyo files will be listed as %ghost
+files.  The directry and all subdirectories will be listed as %dir files.
+DIRECTORY_TO_ADD must begin with a '/'.
+Output will be to PREFIX.pyfiles
+EOF
+exit 1
+}
+
+if [ -z "$1" ] ; then usage
+elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
+elif [ ! -d $1 ] ; then
+ echo $0: $1: no such directory
+ exit 1
+else DESTDIR="`echo $1|sed -e 's:/$::'`"
+fi
+shift
+
+if [ -z "$1" ] ; then usage
+elif [ `expr substr $1 1 1` != '/' ]; then usage
+else DIRNAME=$1
+fi
+shift
+
+if [ -z "$1" ] ; then usage
+else OUTNAME=$1.pyfiles
+fi
+shift
+
+echo "%defattr (644, root, root, 755)" > $OUTNAME
+find $DESTDIR$DIRNAME -type d | sed 's:'"$DESTDIR"'\(.*\):%dir \1:' >> $OUTNAME
+find $DESTDIR$DIRNAME -not -name '*.pyo' -not -type d | sed 's:'"$DESTDIR"'\(.*\):%dir \1:' >> $OUTNAME
+find $DESTDIR$DIRNAME -name '*.pyo' -not -type d | sed 's:'"$DESTDIR"'\(.*\):%ghost \1:' >> $OUTNAME
+
+exit 0

Attachment: signature.asc
Description: This is a digitally signed message part


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]