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 what I ended up doing is creating a directory in `/opt`, install as many deps as possible using the OS' packages (for better security coverage), create a venv there that uses the system packages, and run stuff from there.
@mdione Combining those with system packages sounds like a potentially nice compromise; the lack of centralized updates is one of my concerns about use of venvs, too. Going to try packaging into deb (which worked for a test package now, as mentioned in nearby replies), but this combination of /opt/ with system packages looks like an okay backup option. Thanks.
@defanor @mdione It's worth noting that if you rely on the system package manager to install your Python dependencies, you might be getting pretty out-of-date versions for some of them. Depends on the distro and the package of course, but I've seen Ubuntu packages months out of date in apt, even on the latest Ubuntu release. So you gotta consider the tradeoff between convenience and security, as always.