Policies/Python

From Mandriva Community Wiki

Jump to: navigation, search
Python packaging policy

This document is still a draft, and is not even a complete draft.

Contents


[edit] Tools

[edit] Rules

[edit] Naming

python-foo for module foo, with foo being lower case.

rationale : using a prefix is serving as a name space, and clearly shows how to find python modules.

having everything in lower case is easier to read, and offers a consistent sorting.

[edit] Spec file url

CheeseShop usage for Url ?

[edit] Rpm macro

http://archives.mandrivalinux.com/cooker/2006-01/msg01404.php

[edit] pyc/pyo policy

Files should be compiled before rpm creation and includes as they will otherwise be created if a package is run as root, and therefore created weird bug ( ie, module removed but still here, unowned files ).

To compile the .py moudles, add the following macros to the beginning of the spec:

%define python_compile_opt python -O -c "import compileall; compileall.compile_dir('.')"
%define python_compile     python -c "import compileall; compileall.compile_dir('.')"

Then in the %install section:

dir -d %{buildroot}%{py_platsitedir}/%{name}
%python_compile_opt
%python_compile
install *.pyc *.pyo %{buildroot}%{py_platsitedir}/%{name}

This will create a directory for the software under the platform sitedir, compile the python modules, then copy them to the directory created before. You may use 'pushd directory' before that code and 'popd' after the code if the python modules are in a directory below the root of the tarball.

And finally in the %files section:

%{py_platsitedir}/%{name}/*.pyc
%{py_platsitedir}/%{name}/*.pyo

[edit] Problem

How to handle automated setup and egg.

[edit] example spec file

[edit] rebuild policy

[edit] Policy of other distribution

Personal tools
Ad (via La Vignette)
Looking for a job?