Python Packages
This section describes how to prepare packages which contain
applications written in Python, Python modules and Python language
itself.
What is distributed?
There is no doubt when you create package with Python modules
which sources are written in C language. Sources should be
compiled for given architecture, that's all. The problem arises
when modules are written in Python language. What should be
distributed? Sources - *.py files? Byte compiled files - *.pyc?
Optimized byte compiled files - *.pyo? All of them?
We have decided that packages with Python modules
should contain both, byte compiled and optimized byte compiled
files. Yes, *.pyc and *.pyo files. PLD developers aim to
provide optimized software whenever it is possible.
Why not to distribute only *.py files and byte compile them during
package installation? We want to distribute prepared packages
so user is not forced to compile the sources and such
philosophy applies to Python, too.
Why not only *.pyo files? Firstly, optimized byte compiled modules
cannot be imported without *.pyc files.
Secondly, *.pyo do not contain docstrings - source code
documentation.
Why not only *.pyc files? As it is mentioned above, PLD
developers do not want to deprive users of optimized software.
We want to provide fully optimized Python modules
as we provide packages
optimized for many architectures. It would be not a good idea if
users, which want to use optimized modules, have been forced
to create them manually because it requires root privileges
and creates files which are in /usr hierarchy
and not in RPM database.
Python Modules
RPM Install Section
Python modules can be installed with
autoconf/automake combo
distutils
other method (hand written Makefile files, manual
installation)
Automake 1.5 introduced Python
support. Developers want to use the same tool for
their projects written in Python or C and
automake gives such possibility to them.
Installing Python modules can be done the same way
as installing other applications or libraries, which
authors use automake.
Just remember to pass $RPM_BUILD_ROOT
to DESTDIR, so
make will install source files
(*.py), byte compiled (*.pyc) and optimized byte compiled
(*.pyo) files under $RPM_BUILD_ROOT
hierarchy.
Installing Python modules with Makefile files
created with automake.
%{__make} install DESTDIR=$RPM_BUILD_ROOT
Python distutils
has ability to install optimized and
normal byte compiled files. It can be done with
setup.py script option
--optimize.
Option --root should
be used too, because installed files
should be put in $RPM_BUILD_ROOT
directory.
Installing Python modules in RPM install section
with distutils
python setup.py install --optimize=2 --root=$RPM_BUILD_ROOT
Sometimes distutils
refuses to install files under
$RPM_BUILD_ROOT hierarchy. Set
$PYTHONPATH variable to
$RPM_BUILD_ROOT%{py_sitedir} value
before module installation.
RPM groups
Every package is assigned to RPM
group. Packages which contain developer files such as
header files should be assigned to
Development/Languages/Python
group.
Packages with just modules should be assigned to Libraries/Python group.
Rules used to assign
RPM group to applications, apply
to applications written in Python, too. Taking
sketch for example, the
graphics manipulation program, there is
used X11/Application/Graphics
group. Another example is
happydoc with
Development/Tools group or
ipython with Applications/Shells group.
Standard RPM Macros
Dummy...