Show HN: Cosmofy – bundle your Python code for Linux/Windows/MacOS

8 pointsposted 11 hours ago
by metaist

1 Comments

metaist

11 hours ago

Getting your code running cross-platform used to be really tough. Look at all the different architecture + OS combinations you have to support. Justine Tunney came up with Cosmopolitan libc which lets you compile code into a clever zip file that runs on Linux/MacOS/Windows with no changes.

aghamut published Superconfigure which compiled python (and many other tools) into a "Cosmopolitan Python" file which runs on all those same OSes. What's better is the repo contains a simple recipe for adding your own files to the zip. https://github.com/ahgamut/superconfigure#adding-to-the-zip-...

In 2024, I wrote a post about packaging python apps using Cosmopolitan Python: https://metaist.com/blog/2024/08/packaging-python-with-cosmo...

This morphed into a Cosmopolitan Python App that makes Cosmopolitan Python Apps: https://metaist.com/blog/2024/09/cosmofy-0.1.0.html

But it was very limited: it couldn't handle dependencies at all. So I decided to rewrite the whole thing around `uv` (which handles dependencies _very_ well).

Along the way, I learned how to emulate parts of the Python CLI from _within_ python: https://metaist.com/blog/2024/09/pythonoid.html

I also learned how to emulate uv's style (both in subcommand structure and colored output): https://metaist.com/blog/2025/12/emulating-astral-cli.html

And I learned when to limit emulation (in the name of good design) when trying to implement parts of `ls`: https://metaist.com/blog/2025/12/emulating-ls.html

There's a surprising number of moving parts, but I'd love to get feedback on what works / could be improved.