Live data from Hacker News

Self-contained highly-portable Python distributions

gregoryszorc.com

31–40 of 45 posts

Re: Self-contained highly-portable Python distributions

#31

Earlier quoted context omitted.

> When you download Python from http://python.org (on Linux or macOS), what you're actually downloading is an installer that builds Python from source on your machine. > The net effect is that on Linux and macOS, you can't "download a Python binary" from... anywhere. Other than the python-build-standalone project. Are you sure this is right about macOS? I just had a look inside the macOS installer from python.org and…

It’s incorrect for Linux too, distributions build Python binaries for their repos.

The thread does mention that:

> (The notable exception here is that Linux distros _can_ support, e.g., `apt install python3` and ship a binary, because IIUC they can rely on standardized system paths.)

Of course, there are lots of use cases where that doesn't suffice, such as, for example, if you care what Python version you're using.

Re: Self-contained highly-portable Python distributions

#32

I keep meaning to explore compiling Python +libs to WASM for running in a desktop environment. It is already Python, so I am willing to accommodate enormous performance losses. I just want to package up the code into something more straightforward than PyInstaller.

JavaScript has module bundlers that will merge all your code modules into one module for deployment. It's a little surprising nobody (that I'm aware of) has done this for Python and PEP 723 dependency specifications. Then the single binary for uv is all that's required to run the bundle using this type of approach, at least on unix-ish machines (not sure if there's a trick to make this work on Windows): https://docs.…

Python lets you bundle all the modules in a zip file and run that (no third-party tools needed): https://docs.python.org/3/library/zipapp.html

Re: Self-contained highly-portable Python distributions

#33

Earlier quoted context omitted.

That’s not a bad idea. uvx feels like a temporary hack on which I can’t rely for a permanent deployment, but it is all probably fine. I would want to at least materialize a real environment so I know that it is not getting randomly deleted as cache/temp gets cleared. Unfortunately, it’s still not my ideal use case of distributing executables to Windows machines. I really want a single artifact users could freely shar…

pyexe and pyinstaller let you just ship an exe to run

They just unzip the Python executable and your source files to a temporary directory and run them from there (although they are a convenient way of doing that).

nuitka is a bit better (in the sense of not running executables from a temporary path) in that it really compiles your code into an executable in "standalone" mode.

Re: Self-contained highly-portable Python distributions

#36
> library dependencies are either distributed with the distribution or are statically linked.

I have messed up my packages multiple times and have feared installing anything due to it. I always prefer this type of distributions for any software and now, it works like a charm.

Re: Self-contained highly-portable Python distributions

#37
post #28

These are the Python distributions we use in uv ( https://github.com/astral-sh/uv ), i.e., when you install Python with uv, you're installing from python-build-standalone. (Same goes for many of the other tools that can install Python for you, like pipx, Hatch, Poetry, Bazel, etc.) Most of our engineering time on the project over the past ~year and a half has been split into three buckets: 1. Keeping up with upstream…

mise uses these as well and adopting them has been a massive improvement in the user experience for my python users. y'all have been doing a fantastic job maintaining them. i'm also doing the same for ruby—maintaining the binaries myself which is becoming the default in mise next week: https://github.com/jdx/ruby i'm a firm believer that pre-compiled, portable binaries are the best way to distribute runtimes and clis…

The combo of mise + UV has made my development environment setup/recreation so seamless. We've come a long way.

(Props to your work on mise)

Re: Self-contained highly-portable Python distributions

#39
post #7

There is also the APE/Cosmopolitan cross platform binaries, which includes a python. Yes, cross platform binaries. The binaries run "natively on Linux + Mac + Windows + FreeBSD + OpenBSD 7.3 + NetBSD + BIOS with the best possible performance and the tiniest footprint imaginable." * Python Source: https://github.com/jart/cosmopolitan/tree/master/third_party... * Python Binary: https://cosmo.zip/pub/cosmos/bin/python w…

so in theory, one could program a game in python and then complete and distribute one binary for everyone?
Post reply on HN