From Fedora Project Wiki
Warning.png
This wikipage contains just my personal notes.

The use case I have in mind: as an author of a Python module or an application, I would like to create and maintain Python packages, both in a native way (installable via pip) and linux distro specific one (eg. rpm for fedora).

Workflow which makes most sense (imho) follows. The main ideas are:

  • follow upstream recommendations (upstream first approach, yay!)
  • use distro specific tools to automate maintenance of it's packages

Python packaging

One should start with Python Packaging User Guide (PyPUG) which is maintained by Python Packaging Authority group. It's really a very useful overview and you should definitely read it (or at least skim through it), it will save you a lot of time later in the process. See also the PyPA example project which follows these guidelines. Especially when starting a new python project, there is a no good reason to ignore this guide.

On top of that, there is a nice talk discussing how to use setuptools in the most easier way and what features are better to be avoided: less known packaging features and tricks.

Linux distro packaging

Let's start with the distribution guides:

In short: don't create packages manually and don't use tools like bdist_rpm, but start with distro specific automatic tools which creates initial specfile of your project for you instead. In that way, you will have a specfile which follows the guidelines almost for free. That said, you should still have at least a basic idea what distribution guidelines states, so that you can check the initial autogenerated file and tweak details it when necessary. You can't expect that the tool will get every detail right in all cases.

List of python packaging helper tools: