Marc,
I am CCing debian-python as that mailing list often fields Python related
packaging questions, and you are more likely to get good Python related
responses there than debian-mentors.
Most Python packages are maintained in the Python team namespace, which is a
very active team. I would recommend you consider joining the team.
https://salsa.debian.org/python-team/tools/python-modules/blob/master/
policy.rst
I don’t really know very much Python, but I have ended up maintaining a lot of
Python packages, mostly by accident. So, take everything I say here with a
grain of salt and I am happy to have anyone on debian-python correct me if I
am wrong.
On Monday, June 23, 2025 12:38:08 PM Mountain Standard Time Marc Haber wrote:
> Hi,
>
> I am re-working my first Debian package, console-log, which I wrote back
> two decades ago. The rewrite is going to be in python, and I have never
> packaged python code before. The code is not yet in git.
>
> What I have:
> .
> ├── debian
> │ ├── changelog
> │ ├── control
> │ ├── copyright
> │ ├── rules
> │ └── source
> │ └── format
> ├── pyproject.toml
> └── src
> ├── console_log
> │ ├── base.py
> │ ├── config.py
> │ ├── __init__.py
> │ └── pagers
> │ ├── __init__.py
> │ └── less.py
> ├── console-log.generator
> └── do_console_log
>
> console-log.generator will go to
> /usr/lib/systemd/system-generators; do_console_log ends up in
> /usr/share/console-log. Both programs are not supposed to be called from
> a user. do_console_log imports from console-log/pagers. There will be
> other modules at the side of less.py. I am moving both from
> debian/console-log.install.
>
> Google tells me that I am supposed to use dh-python and pyproject. Here
> is what I coughed up:
>
> [206/6622]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) $
cat
> debian/rules #!/usr/bin/make -f
>
> %:
> dh $@ --with python3 --buildsystem=pybuild
“--with python3” is considered deprecated syntax, although it still works.
The replacement is to build-depend on “dh-sequence-python3”. Here is an
example:
https://salsa.debian.org/python-team/packages/python-construct-classes/-/blob/
debian/master/debian/control?ref_type=heads#L7
> [207/6622]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) $
cat
> pyproject.toml [build-system]
> requires = ["setuptools>=61.0", "wheel"]
> build-backend = "setuptools.build_meta"
>
> [project]
> name = "console-log"
> version = "2.0"
> description = "Console Log - Displays Logs on Virtual Consoles"
> authors = [
> { name = "Marc Haber", email = "mh+debian-packages@zugschlus.de" }
> ]
> license = "GPL-2.0"
> requires-python = ">=3.7"
> dependencies = [
> ]
>
> [tool.setuptools.packages.find]
> where = ["src"]
> [208/6623]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) $
>
> However, building this does not seem to give the desired results:
>
> (1)
> My package contains /usr/lib/python3/console_log-2.0.dist-info, and
> lintian doesn't like that. How can I preent that from being installed?
Nothing should be installed directly into /usr/lib/python3/. Rather, all your
Python modules and dist-info should be installed into /usr/lib/python3/dist-
packages.
> (2)
> Additionally, the package doesn't build twice in a row since .pybuild
> and build directories are generated and not cleaned up on package clean.
>
> Am I supposed to clean those two directories up in dh_override_auto_clean?
Not typically. I have never had to do that with a Python package. Perhaps
there is something you are missing that someone on debian-python can point
out.
From a big picture, if your source package is only building one binary
package, you can include the following in debian/rules and a lot of the
packaging is automatic:
export PYBUILD_NAME=package-class-name
This generates a binary package named python3-package-class-name and puts
things in the right place. For example:
https://salsa.debian.org/python-team/packages/python-construct-classes/-/blob/
debian/master/debian/rules?ref_type=heads#L3
There are ways to make this work if you have more than one binary package, but
I find those things to be a bit complex. In that case, you can leave out the
PYBUILD_NAME variable and use debian/*.install files.
> (3)
> Is it okay to move the two binaries from src/ to the respective
> directories in the package via debian/console-log.install or, how would I
> tell setuptools to install those files to their targets?
Any way that works is probably fine. In looking at other packages, I have
seen it done with debian/*.install or in debian/rules with
execute_after_dh_auto_install. Note that if you go the PYBUILD_NAME route I
think you need to use debian/rules.
--
Soren Stoutner
soren@debian.orgAttachment:
signature.asc
Description: This is a digitally signed message part.