Discussion:
RPM Build Problem: installed but unpackaged .pyo and .pyc files
Beth Stetzler
2008-08-05 15:41:43 UTC
Permalink
Hello,

I have made a .spec file to build an RPM that is to install some shell
scripts and Python scripts. The Python scripts are giving BUILD
errors. The errors say that the .pyo and .pyc files are installed but
not packaged. I understand Python compiles these at runtime. I'm
hoping someone can assist with how to fix these problems. I have tested
the .py scripts, but I do not see the .pyc and .pyo files. They are not
in the tarball I created. Would Python have put them in a random
location? My Python version is 2.4 and the library directory site
packages is /usr/lib/python2.4/site-packages.

Thanks.
G***@aotx.uscourts.gov
2008-08-05 15:48:14 UTC
Permalink
Post by Beth Stetzler
I have made a .spec file to build an RPM that is to install some shell
scripts and Python scripts. The Python scripts are giving BUILD
errors. The errors say that the .pyo and .pyc files are installed but
not packaged. I understand Python compiles these at runtime. I'm
hoping someone can assist with how to fix these problems. I have tested
the .py scripts, but I do not see the .pyc and .pyo files. They are not
in the tarball I created. Would Python have put them in a random
location? My Python version is 2.4 and the library directory site
packages is /usr/lib/python2.4/site-packages.
I usually like my files like this, but you could always go look the some
spec files of other apps that would do the same (off the top of my head one
might be labyrinth).


path/file.py
%ghost path/file.pyc
%ghost path/file.pyo

not sure if there is a better way

-greg
Paul Johnson
2008-08-05 18:42:51 UTC
Permalink
On Tue, Aug 5, 2008 at 10:41 AM, Beth Stetzler
Post by Beth Stetzler
Hello,
I have made a .spec file to build an RPM that is to install some shell
scripts and Python scripts. The Python scripts are giving BUILD errors.
The errors say that the .pyo and .pyc files are installed but not packaged.
I understand Python compiles these at runtime. I'm hoping someone can
assist with how to fix these problems. I have tested the .py scripts, but I
do not see the .pyc and .pyo files. They are not in the tarball I created.
Would Python have put them in a random location? My Python version is 2.4
and the library directory site packages is /usr/lib/python2.4/site-packages.
I know of some bandaids for this.

1. Fix your spec file to add the pyc files. Go to your %files directive.

2. Tell RPM to ignore the unpackaged files.
Put this at the top of the spec file:

%define _unpackaged_files_terminate_build 0

3. Install the package "checkInstall". That will generate an RPM "on
the fly" after a make. You will see exactly where all the installed
files go. It does not check anything, it does not make a fully
legitimate spec file. But it does help you see where all the things
get put.

A deeper approach is to fix the install. My python knowledge is
limited, but I *believe* that the you might be smart to keep the pyc
files because they will execute faster than the py versions. Python
won't re-generate the pyc file if it is current, ie based on same py
file as you have. I don't see pyo files resulting from "make
install". I do see them after make.

Other poster is correct. You should get some SRPM files from python
programs and study their spec files.

pj
--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas
Matthew Miller
2008-08-05 19:00:04 UTC
Permalink
Post by Paul Johnson
A deeper approach is to fix the install. My python knowledge is
limited, but I *believe* that the you might be smart to keep the pyc
files because they will execute faster than the py versions. Python
won't re-generate the pyc file if it is current, ie based on same py
file as you have. I don't see pyo files resulting from "make
install". I do see them after make.
Other poster is correct. You should get some SRPM files from python
programs and study their spec files.
It's not necesaarily a general solution for all distributions, but here's
the Fedora guidelines for this:

<http://fedoraproject.org/wiki/Packaging/Python#Byte_Compiled_Files>

In a nutshell, include 'em in %files.
--
Matthew Miller ***@mattdm.org <http://mattdm.org/>
Boston University Linux ------> <http://linux.bu.edu/>
Beth Stetzler
2008-08-05 19:32:10 UTC
Permalink
Just wanted to say thanks to Tim, Greg, and PJ for your combined help.
I got my RPM to build and install.

Loading...