Python package packaging question

Mike A. Harris mharris at redhat.com
Tue Feb 3 08:41:45 UTC 2004


On Mon, 2 Feb 2004, Nalin Dahyabhai wrote:

>Date: Mon, 2 Feb 2004 16:55:58 -0500
>From: Nalin Dahyabhai <nalin at redhat.com>
>To: fedora-devel-list at redhat.com
>Content-Type: text/plain; charset=us-ascii
>List-Id: Development discussions related to Fedora Core
>    <fedora-devel-list.redhat.com>
>Subject: Re: Python package packaging question
>
>On Mon, Feb 02, 2004 at 04:18:09PM -0500, Mihai Ibanescu wrote:
>> It may seem like it. .pyc and .pyo files are there for performance 
>> reasons. .py files are there, because debugging would be a nightmare 
>> otherwise.
>
>The byte-compiled versions will always be generated if you have write
>access to the directory.  (This is almost always the case if you happen
>to run a script as root.)  If you run a script as root and then attempt
>to uninstall the package which includes that script, some directories
>which are unique to the package can't be removed because the .pyc and
>.pyo files are still there (even though the .py files are now gone).
>
>Some packages include the byte-compiled versions of their scripts to
>avoid this.  Personally I think all packages which include python
>scripts should include both the .pyc and .pyo files (and that the
>default RPM configuration should automate this), but I don't think
>there's ever been a consensus on that.

For the case in which the .pyc and .pyo files are not included in 
the rpm package, the best solution IMHO, is to have the rpm 
package do the following for those files:

%ghost %verify(not md5 size mtime) /path/to/foo.py[co]

Of course, the end of %install section of spec file needs to 
'touch' all of those files so they exist in the buildroot for 
packaging.

When the package is uninstalled, if I recall correctly, rpm will 
delete those files even though they weren't included with the 
installation to begin with.  The %ghost makes the package own 
them.

-- 
Mike A. Harris     ftp://people.redhat.com/mharris
OS Systems Engineer - XFree86 maintainer - Red Hat





More information about the devel mailing list