Path: csiph.com!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.szaf.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod From: Soren Stoutner Newsgroups: linux.debian.devel.mentors,linux.debian.maint.python Subject: Re: need help for my first python package Date: Mon, 23 Jun 2025 22:00:01 +0200 Message-ID: References: X-Mailbox-Line: From debian-mentors-request@lists.debian.org Mon Jun 23 19:59:34 2025 Old-Return-Path: X-Amavis-Spam-Status: No, score=-115.916 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, BODY_8BITS=1.5, DKIMWL_WL_HIGH=-2.907, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, LDO_WHITELIST=-5, PGPSIGNATURE=-5, RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001, USER_IN_DKIM_WELCOMELIST=-0.01, USER_IN_DKIM_WHITELIST=-100] autolearn=ham autolearn_force=no Organization: Debian Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEWIg4F7bGiws7ReTkyy kYoXFRrd6/4yMA0PAAACaklEQVQ4y22TwXabMBBFJaPuNZGSNZZp1uhM6BpkJeu4VFk3bsL/f0Lf CHC6qHyOgbl68zTDoIwaVfh3tUopTUGpbFToDiFnY9IY2oMAZYMiS4R9SfbSXepSS5EcFAa/muIU aRj8mkoUqrEraFzhYegBmqig0LyCIyM8DAwPlpBqmJVYaD2UeWZ3abVjsqKIojg+hY4omsyIcNSi qIBM6jJWOveS6kvBeVvHJ+VYzJUW88RmA12UiBx3HEcUMRuzIZI6tBQovTrPclNB3AuUXoXvs0XY C3B2baJpW4Dn2ZpVMInCirkxoyhM1qpK5nFrO65QvCrCqql2DyPgvm94iMQz5/PmISuEotxQGMD5 M5G1N9CjXJ5HQH96BZG2xx6AzejYZccxT4Re3Zr4bPKkCcGcz5Or3dVEABkAUY/znnVcQVVkrXVU vomoEJFe7x4nQuaZmZELL6qnXZGIB5YV/Q2IogtSmyNybEcBX2+QCLOAQYm+gmoORUrYzV7dc6R2 T1WPm45oVEQqsjtoIovHyTmcyxMhVVxTqapomZyLlAmTKC9AmjgamXXGZo+epNrXO3wGGiPRHbKL FnMy2RRgRb1gzFXXGjhICp8wqaTtdtyQH6nWTfkatJvJJoUCbOjSC7wR9/naEVognxrOFdLh7Ugx QpA/0QT4pRV0+u2dqsXD5y9EBDjVAJS3ZZLxmZblgmsU8x7mBeCKg48Py7WU2IiH1epbEbC8K9Ms y0cpcySVUcdQVrBY+rEsv+XpYgFKXT8B3v2yATxv8fKK2EfC358tsIMLYqfD401xA0j1EY4P/wWf IbhlOWyBv4OQsywBM8MAAAAAAElFTkSuQmCC MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2876582.BEx9A2HvPv"; micalg="pgp-sha512"; protocol="application/pgp-signature" X-Debian-User: soren X-Mailing-List: archive/latest/115942 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/2272014.NgBsaNRSFp@soren-desktop Approved: robomod@news.nic.it Lines: 195 Sender: robomod@news.nic.it X-Original-Cc: Marc Haber , Debian Python X-Original-Date: Mon, 23 Jun 2025 12:59:03 -0700 X-Original-Message-ID: <2272014.NgBsaNRSFp@soren-desktop> X-Original-References: Xref: csiph.com linux.debian.devel.mentors:47666 linux.debian.maint.python:16945 --nextPart2876582.BEx9A2HvPv Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Soren Stoutner To: debian-mentors@lists.debian.org Subject: Re: need help for my first python package Date: Mon, 23 Jun 2025 12:59:03 -0700 Message-ID: <2272014.NgBsaNRSFp@soren-desktop> Organization: Debian In-Reply-To: References: MIME-Version: 1.0 Marc, I am CCing debian-python as that mailing list often fields Python related=20 packaging questions, and you are more likely to get good Python related=20 responses there than debian-mentors. Most Python packages are maintained in the Python team namespace, which is = a=20 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=E2=80=99t really know very much Python, but I have ended up maintaini= ng a lot of=20 Python packages, mostly by accident. So, take everything I say here with a= =20 grain of salt and I am happy to have anyone on debian-python correct me if = I=20 am wrong. On Monday, June 23, 2025 12:38:08=E2=80=AFPM Mountain Standard Time Marc Ha= ber wrote: > Hi, >=20 > 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. >=20 > What I have: > . > =E2=94=9C=E2=94=80=E2=94=80 debian > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 changelog > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 control > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 copyright > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 rules > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 source > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 format > =E2=94=9C=E2=94=80=E2=94=80 pyproject.toml > =E2=94=94=E2=94=80=E2=94=80 src > =E2=94=9C=E2=94=80=E2=94=80 console_log > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 base.py > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 config.py > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 __init__.py > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 pagers > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 __init__.py > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 less.py > =E2=94=9C=E2=94=80=E2=94=80 console-log.generator > =E2=94=94=E2=94=80=E2=94=80 do_console_log >=20 > 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. >=20 > Google tells me that I am supposed to use dh-python and pyproject. Here > is what I coughed up: >=20 > [206/6622]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) = $=20 cat > debian/rules #!/usr/bin/make -f >=20 > %: > dh $@ --with python3 --buildsystem=3Dpybuild =E2=80=9C--with python3=E2=80=9D is considered deprecated syntax, although = it still works. =20 The replacement is to build-depend on =E2=80=9Cdh-sequence-python3=E2=80=9D= =2E Here is an=20 example: https://salsa.debian.org/python-team/packages/python-construct-classes/-/bl= ob/ debian/master/debian/control?ref_type=3Dheads#L7 > [207/6622]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) = $=20 cat > pyproject.toml [build-system] > requires =3D ["setuptools>=3D61.0", "wheel"] > build-backend =3D "setuptools.build_meta" >=20 > [project] > name =3D "console-log" > version =3D "2.0" > description =3D "Console Log - Displays Logs on Virtual Consoles" > authors =3D [ > { name =3D "Marc Haber", email =3D "mh+debian-packages@zugschlus.de"= } > ] > license =3D "GPL-2.0" > requires-python =3D ">=3D3.7" > dependencies =3D [ > ] >=20 > [tool.setuptools.packages.find] > where =3D ["src"] > [208/6623]mh@swivel:~/packages/console-log/console-log (wip-systemd *+%) $ >=20 > However, building this does not seem to give the desired results: >=20 > (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 y= our=20 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. >=20 > 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= =20 there is something you are missing that someone on debian-python can point= =20 out. =46rom a big picture, if your source package is only building one binary=20 package, you can include the following in debian/rules and a lot of the=20 packaging is automatic: export PYBUILD_NAME=3Dpackage-class-name This generates a binary package named python3-package-class-name and puts=20 things in the right place. For example: https://salsa.debian.org/python-team/packages/python-construct-classes/-/bl= ob/ debian/master/debian/rules?ref_type=3Dheads#L3 There are ways to make this work if you have more than one binary package, = but=20 I find those things to be a bit complex. In that case, you can leave out t= he=20 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= =20 seen it done with debian/*.install or in debian/rules with=20 execute_after_dh_auto_install. Note that if you go the PYBUILD_NAME route = I=20 think you need to use debian/rules. =2D-=20 Soren Stoutner soren@debian.org --nextPart2876582.BEx9A2HvPv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEJKVN2yNUZnlcqOI+wufLJ66wtgMFAmhZsgcACgkQwufLJ66w tgNPYRAAg1YSHHdDIUTr0OCdH/9I0hrriQgIIErZ1Z4tmscB9t0XO2OS7rTJ7tJZ yQc/Bb3eXs2tp2/eNPAeJCr5FjE3kMkJCu8R0NVpZoV+JGKsFHuU1VTd01UpA/cE gDu8fS2IuCUPhTcUSkLjKCeynt/0UnC+ZnwH+T5Vt1+oLJolj2F1fCcWysGB91/K ulNwoE+xrruEAjpET3hWIpCmP1cJik8LbN+WkuXRayUhiuxVkUp2XiK7wH7KBe8n HJcppVdZ36ZJIRx5iPQ/8evvhJFSWqIbsAqM77AqCEoGXLrTNyHkI6lFHhkrybid dFof1kjUiekTi/VNdpiy1qfDvCLRqU2mc7XifR2sacVht35Wwm7ZNF4b5kAGTD5T 4AgjVn5g26Df9ytd9GAWx7d4lz2Q79WzkOeXVw1OWu1ugaU7ZkJPhGSjyjmH5UR/ KMktxVatb5dZERN4En+WpqUCg6g6bLd0MqugnK5Kqc7cNr0ZlmawdAUsS45v3Seg IUtUjq+PaYUMbvmpCeGleXcxE0l5NUsA4yQQym+PR/i02Fv+qDhAnRdibhV5vA+6 BGLSTkSPAl9huDkdjIaX8vacyX6LskiyPO+ZclXftiEdBSrtUzA5ZCRgZe9/lUrg iH0bMKtPYTGMCEmhX0wcPPYads/Tgk4LU3iPP1usH5CQ0gyAs58= =UrSV -----END PGP SIGNATURE----- --nextPart2876582.BEx9A2HvPv--