[Python-apps-team] How to package a program for python2 or python3?

Ben Finney ben+debian at benfinney.id.au
Fri Oct 25 06:38:42 UTC 2013


Rogério Brito <rbrito at ime.usp.br> writes:

> I maintain a moderately popular program called youtube-dl that is
> currently set up to run in Debian with Python 2.

Thank you for maintaining this application for Debian users.

> I think that there is no reason why I should be restricting youtube-dl
> to pull a Python 2 interpreter when a Python 3 interpreter is already
> present and, indeed, I would like to fix this.

Great! This is what the Debhelper Python tools (and, IIUC, the Debian
version of Python Distribute) have recently been working toward: Making
it easier to create separate binary packages for Python 2 and Python 3
from the same source.

You probably already know that the Debian Python Policy §1.1 (in
<URL:http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html>)
says “As far as is reasonable, python and python3 should be treated as
separate runtime systems with minimal interdependencies.”

So, if you're going to target Python 2 and Python 3, you need to make
separate binary packages for those separate runtime systems.

> Unfortunately, while youtube-dl used to be a single file script in the
> past, it is, nowadays, distributed as a bunch of modules (which is
> good for maintainership, but bad for distributors).

The division into modules isn't particularly problematic and is, as you
say, a good practice.

What is problematic is the OS-unfriendly nature of the standard Python
installation tools, making it difficult to install packages to
FHS-conformant locations. But here again I think the Debhelper tools for
Python are useful at smoothing these edges.

> So, given the situation above, what is the best-current-practice that
> I should follow? I would sincerely like to avoid creating a separate
> binary package, if possible.

Why is that? I think it is normal practice in Debian's Python packages
to target Python 2 and Python 3 with separate binary packages. If you
can say what in particular you'd like to avoid, maybe a solution can be
suggested.

-- 
 \        “Like the creators of sitcoms or junk food or package tours, |
  `\         Java's designers were consciously designing a product for |
_o__)                       people not as smart as them.” —Paul Graham |
Ben Finney




More information about the Python-apps-team mailing list