These days I try to avoid interpreted CLI tools, you never know when they’re going to stop working.
Rust/Go CLI tools basically work on Linux, Max, Windows without too much fuss.
Wish someone would rewrite Homebrew in Rust!
These days I try to avoid interpreted CLI tools, you never know when they’re going to stop working.
Rust/Go CLI tools basically work on Linux, Max, Windows without too much fuss.
Wish someone would rewrite Homebrew in Rust!
Things like httpie, jupyter, etc should be provided as pyz and binaries as well, not just pip installable, but python devs don't do that really often.
It's a shame, because cli tools should be black boxes, people should not have to think about the implementation. I regularly see cli python tools that output stack traces on errors, and it should not happen.
Anyway, if you want those tools to be always around, I really encourage you to grap a usb stick, and put them on there as pyz and binaries. It's always nice to have them at hand.
Here is an example procedure for both (run them in a venv).
For pyz files:
python -m pip install shiv --user # (Yes, I realize how ironic this is).
Then: python -m shiv httpie -o http.pyz -c http
(download httpie, and creates a http.pyz file that will contains httpie and all it's dependancies, plus code to trigger the http command when called)This will let you do "python http.pyz" anywhere you have a modern python and enjoy httpie without the need to pip install it.
For an exe (this is an example on linux, the commands are a bit different for windows and mac):
python -m pip install nuitka httpie --user
You need to have a C compiler and python headers around as well (gcc on linux will do, E.G: sudo apt install build-essential python3-dev on ubuntu).Then:
python -m nuitka $(which http) --onefile --linux-onefile-icon /usr/share/pixmaps/python3.xpm --follow-imports --assume-yes-for-downloads
Wait quite a bit.Now you have a nice stand alone AppImage you can call with ./http.bin to be used on any linux system, and not care if Python is installed to play with httpie.
Here are the resulting files (available for 5 days) so you can see what it looks like:
https://drop.chapril.org/download/a335a8e92f98ee02/#fHC1SvOw...
Nuitka produces a standalone exe so no need to install python.
Basically Rust ignores SIGPIPE, so if you don't use write!() or handle SIGPIPE yourself, large amounts of data going through a shell pipe can result in a panic.
I wonder how many Rust CLI tools have the issue.
(EDIT: talking about Python packages specifically, not so sure about other things)
As you say, if something doesn't work due to conflicting dependencies, usually creating a virtualenv solves it. I don't bother these days, as just installing everything with --user tends to always work.
The real problems start when people write scripts and notebooks etc that use libraries that might just happen to be installed or, even worse, install new libraries. The only solution to that is often a scorched earth approach where you vow to never install anything outside a venv again.
Since you are sort of making the connection for Homebrew to work without fuss on Linux and Windows as well, if implemented in Rust, I am asking myself what it would offer that a user of Linux and Windows is missing?
Ordinary Linux distributions already have a package management and there is scoop and chocolaty for Windows.
Personally, being a user of Homebrew on macOS I’ve been thinking about wanting brew to be rewritten in Rust too. My own reason being that I think it would be faster when run, compared to the version they have of it currently which can be quite slow sometimes. And because I like Rust as a language and for its memory safety features. So I’d rather see brew implemented in Rust than in say C or C++, if a compiled language was to be used.
I mainly want it to be rewritten in a compiled language for performance reasons, it's a sluggish beast. I haven't tried to use it on Linux (where it has some support), and definitely not on Windows (winget/chocolatey would be my port of call there).
Examples of tools I use across operating systems that were written in Rust/Go, that pretty much are drop an executable somewhere and run:
ripgrep, starship, tailscale, terraform, vault, etc.
Whereas when something is written in Python, Ruby or similar, I'm rolling the dice, and I'm only an apt-get or dnf away from it breaking when I really need it.