Skip to content
← Back to blog

November 19, 2026 · 3 min read

Packaging a Python app for any Linux, with its own Python inside

My audio transcriber, transcribe, installs with pacman, apt or dnf and doesn't depend on the system Python: it brings its own. Portable Python, 200 MB left out with a stand-in module, and a test that transcribes a synthetic voice on six distros.

In this post
  1. The system Python isn’t yours
  2. Portable Python
  3. 200 MB that weren’t needed
  4. nfpm: one file, three formats
  5. The test: transcribe a real voice
  6. What I learned

transcribe is my program for turning audio and video into text from the terminal, offline. It used to install with uv tool install or pipx. That works, but only for people who already know what those are. With repo.rossmel.com running, I wanted it to install like any program: sudo pacman -S ross-transcribe-bin, sudo apt install ross-transcribe or sudo dnf install ross-transcribe.

The problem with packaging a Python app for several distros is Python itself.

The system Python isn’t yours

Every distro ships its own Python version: Ubuntu 22.04 one, Fedora another, Arch the newest. transcribe depends on faster-whisper, which depends on CTranslate2, which ships binaries built for specific Python versions. Installing all that into the system Python means fighting each distro’s package manager, and Debian and Ubuntu flat out refuse a global pip install.

The way out was not to use the system Python: the package brings its own Python.

Portable Python

python-build-standalone publishes CPython builds you can unpack into any folder and run on any reasonably modern x86_64 Linux. It’s what uv uses under the hood.

The packaging script:

  1. Downloads a pinned CPython 3.12 build and checks its published SHA-256. If the file changes, the build fails.
  2. Unpacks it into /opt/ross-transcribe/python.
  3. Installs transcribe and its dependencies with that Python’s pip, and checks the installed version is the one being packaged.
  4. Creates the /usr/bin/transcribe and /usr/bin/transcribir commands (the same tool, Spanish by default).

200 MB that weren’t needed

Installed as is, faster-whisper pulls in two dependencies transcribe doesn’t use:

  • PyAV (about 130 MB, with its own FFmpeg): faster-whisper uses it to decode audio, but transcribe decodes with the system’s ffmpeg.
  • onnxruntime (about 65 MB): only for an optional voice filter transcribe doesn’t turn on.

Uninstalling them breaks something: faster-whisper runs import av when it loads, even if it never calls it. The fix was a stand-in module: a minimal av package that exists so the import works, and gives a clear error if anyone actually tries to use it. After trimming, the script checks the imports still work; if not, the build fails.

pip, the standard library’s tests, tkinter and the build headers stay out too. The final package came out at about 125 MB.

nfpm: one file, three formats

To build the .deb, the .rpm and the .pkg.tar.zst I use nfpm, which takes one YAML file and produces all three. Each format lists its dependencies under its own names: ffmpeg on Debian; on Fedora, the file /usr/bin/ffmpeg, so any package that installs it will do; and fd-find as a recommendation so the whole-machine search is faster.

The test: transcribe a real voice

A package that installs isn’t a package that works. Before every release, GitHub Actions installs the package in clean Arch, CachyOS, Ubuntu 22.04 and 24.04, Debian 13 and Fedora containers, and in each one:

  1. generates a synthetic voice with espeak-ng: “Hello world. This is a quick transcription test.”;
  2. transcribes it with the tiny model;
  3. checks that the text contains “world” and “test”. Not “Hello”: the small model sometimes mishears it, and the test shouldn’t fail because of that.

That test found a bug I would never have seen on my computer: on a clean Debian, transcribe couldn’t download the model because the root certificates were missing. The package now depends on ca-certificates.

What I learned

  • For a Python app with binaries, bringing your own Python is simpler than adapting to each distro’s.
  • Checking what takes up space pays off: two unused dependencies added up to about 200 MB.
  • A stand-in module can remove a dependency that’s only imported, as long as a test confirms nothing uses it.
  • The install test has to do the real work (transcribe), not just run --version.

Rossmel Abasto — Frontend → Fullstack Developer. LinkedIn · GitHub

Leer este artículo en español →See the case studytranscribe →A terminal program that turns audio and video into text on your own computer, offline, with timestamps and subtitles. Open source.

Keep reading

Write to me: I read everything and reply by email.

Questions or comments about this post?

send-mail.sh