Any documentation I've found about this topic mentions that the "only" requirement to build a deb package is to have a correct setup.py
(and requirements.txt
). For instance in dh-virtualenv tutorial, stdeb documentation and the Debian's library style guide for python.
But nowadays new (amazing) tools like poetry allow to develop (and upload to PyPI) python projects without any setup.py
(this file and several others including requirements.txt
are all replaced by pyproject.toml
). I believe flit allows this too.
I have developed a python project managed by poetry and would like to package it for Ubuntu/Debian. I guess, as a workaround I can still write a setup.py
file that would take its values from pyproject.toml
and a requirements.txt
file (written by hand using values from poetry.lock
).
But, is there a way to do this without any setup.py
file?
The Python package deb-pkg-tools is a collection of functions to build and inspect Debian binary packages and repositories of binary packages. Its primary use case is to automate builds.
setuptools
, and the setup.py
file that it requires, has been the de-facto packaging standard in python for the longest time. The new package managers you mention were enabled by the introduction of PEP 517
and PEP 518
(or read this for a high-level description on the topic), which provide a standardized way of specifying the build backend without the need of a setup.py
(and the ensuing hen-egg problem where you already need setuptools
to correctly parse it).
Anyway, it's all still very fresh, and the linux packaging community hasn't caught up yet. I found no recent discussion regarding debian packages, but the rpm
side sums it up neatly over here.
So, the short answer is to just wait a while, and google debian packaging pep517 support
every now and then.
Until then, you can use dephell
to generate the setup.py
, and poetry
to generate the requirements.txt
for you as a workaround to keep using the existing tools:
dephell deps convert --from=poetry --to=setuppy
poetry export -f requirements.txt -o requirements.txt
And, during the build, tell your pyproject.tom
that you plan to use setuptools
for the build instead of poetry
:
[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With