debian
debuild
dpkg-buildpackage
python
Using debuild to pack python projecr into debian package
The python project include pyproject.toml
install depend packages
sudo apt install dh-python
sudo apt install pybuild-plugin-pyproject
sudo apt install python3-all
Project basic
using uv to create project files and folders
add debian folder
├── debian
│ ├── changelog
│ ├── control
│ ├── postinst
│ ├── postrm
│ └── rules
├── pyproject.toml
├── README.md
├── src
│ └── py2deb
│ ├── __init__.py
│ └── py.typed
└── uv.lock
control
Source: py2deb
Section: python
Priority: optional
Maintainer: Your Name <you@example.com>
Build-Depends:
debhelper-compat (= 13),
dh-python,
python3-all,
pybuild-plugin-pyproject
Standards-Version: 4.6.2
Package: python3-py2deb
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}
Description: py2deb Python library
Python library installed system-wide using dh-python.
rules
#!/usr/bin/make -f
% :
dh $@ --with python3 --buildsystem= pybuild
override_dh_builddeb :
dh_builddeb --destdir= $( CURDIR) /debs
rule tab indentation
settings.json {
"[shellscript]" : {
"editor.insertSpaces" : false ,
"editor.tabSize" : 4 ,
"editor.detectIndentation" : false
},
"files.associations" : {
"rules" : "shellscript"
}
}
pyproject.toml
[project]
name = "py2deb"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
{ name = "robobe", email = "robobe2020@gmail.com" }
]
requires-python = ">=3.12"
dependencies = []
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"
[dependency-groups]
dev = [
"build>=1.3.0",
]
postinst
- #DEBHELPER#
#!/bin/sh
# debhelper will inject its autogenerated code here
# (triggers, ldconfig, python cache, etc.)
# DO NOT REMOVE
#DEBHELPER#
set -e
case " $1 " in
configure)
echo "Running custom post-install logic"
# your command here
;;
esac
exit 0
postrm
#!/bin/sh
# debhelper will inject its autogenerated code here
# (triggers, ldconfig, python cache, etc.)
# DO NOT REMOVE
#DEBHELPER#
set -e
exit 0
usage
debs folder
debuild create the deb file and other artifacts in project parent folder
using rules control where deb fille will locater but it mess dpkg-buildpackage app default behaver
rules override_dh_builddeb :
dh_builddeb --destdir= $( CURDIR) /debs
TODO
hot to sync pyproject.toml version with changelog / debian package
explain more #DEBHELPER# what are the defaults commends that debuld embedded in postinst and postrm