Looking for ways to install #Python programs on #Debian 11 and 12 systems, globally (as would normally be in /usr/local/bin/ for executables, elsewhere in /usr/local/ for additional files), to run periodically or as daemons (later setting systemd services for those). "Easy install" is deprecated, pip points at the externally managed environment and wants a virtual environment, pipx also installs into a venv in the user's home directory. Executable scripts are available to other users then, but sitting in a user directory, which is unconventional, contrary to the FHS. Packaging into .deb must be possible, apparently using dh-python, though so far I have not found a complete guide to follow, possibly will have to dig deeper into it. Single-file scripts could be simply copied into /usr/local/bin/, but there can be multi-file programs as well. I wonder whether I am missing something: this looks surprisingly tricky for such a task, with a very popular language and a popular Linux distribution. How do you package and install custom Python programs on Debian?
@defanor
> Packaging [a #Python application for #Debian] must be possible, apparently using dh-python, though so far I have not found a complete guide to follow, possibly will have to dig deeper into it.
You're right. This is partly because the landscape for the Python packaging system has never settled, and partly because that system makes it so very difficult to install system-wide working with the operating system existing installed libraries.
Also partly because volunteers lack time.
When I say that volunteers lack time, I'm describing two camps:
The #Debian volunteers who work to support Python, lack time to keep up with the ever shifting "standard way" that is different every few years. Tools get outdated, interfaces never get properly supported.
The #Python stewards wisely don't want to officially crown any one system until it's stable and comprehensively solves the problem. They don't do the work themselves, so defer to the community. Who haven't solved it.
@bignose Thanks! I built a two-module test package now, based on xkcdpass's packaging. The modules are in /usr/lib/python3/dist-packages/, the executable file in /usr/bin/, and systemd service files can be added easily into it. Despite the issues, at least there is a path to a nicely installed program.
I'm glad you got a package working!
@defanor
> The modules are in /usr/lib/python3/dist-packages/
Yeah, that's a huge point of pain. For many applications the internal modules should *not* be in the general #Python import path, polluting the import namespace. These are intended only for the application.
There was a way to specify "install Python modules here, data files there, documentation hither", etc., at install time. That option is gone now, in an explicit snub to application packagers.