by rtpg · 4y ago · 0 comments
I know there are probably other answers (I guess writing binaries in Go?), but given how nice Python is for glue code when it works, I do wish for something like `python --config-file pyproject.toml my-script.py` that would figure out requirements, install those "somewhere", ensure the right python version (installing if necessary) and then run the script in a consistent environment (PYTHONPATH being reset, for example).
I know there's a lot of tools for packaging Python code into their own binaries, but I think we could probably get pretty far with some built-in "install and run" tooling that doesn't start with "decide where to put a virtualenv"
FWIW, Python is not shipped with macOS anymore:
https://www.macrumors.com/2022/01/28/apple-removing-python-2...
At the very least you need Xcode Command Line Tools.
Perl still comes with MacOS 12.3. And Perl would be a decent language to bootstrap a working Python with working certificates, etc.
Though Apple has said all scripting languages will be removed from the default install eventually.
"Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app."
>I guess writing binaries in Go?
Then you get the fun of signing, or README language to guide the user around adding an exception. They sure are making bootstrapping hard. I wish they would pick at least one stable scripting environment to bundle...lua maybe?
If the state of the art in Perl is still "shell out to curl or whatnot" then that is really not portable or stable compared to Python's included urllib--SSL errors or not.
HTTP::Tiny ships with Perl, including 5.16. I'm not sure if MacOS Perl comes with a working IO::Socket::SSL you would need for https.
Edit: See if this works or not:
perl -MHTTP::Tiny -E 'say HTTP::Tiny->new->get("https://www.google.com/")->{content}'It's OK for me if there is a single binary that is "guaranteed" to work that also needs to be installed (for example "you have to install nix/tox"), similar to people having to install a JVM (which mostly works relative to Python).
And yeah you can use curl for web requests. But when your problem then becomes "make a web request, take a chunk out of that" you're looking at curl _and_ jq. And clean error handling...
I know how to write shell scripts, but I think I hit their abstraction ceilings way too early, especially if I'm looking to write something that is maintainable by other people on the team. I know people talk about how every machine will have some shell, but when you think about it a bit more all the "nice" shell utils are not installed by default.
All the more power to people who can write clean shell scripts. I try to, but am not good at it. But I know how to write Python (or JS, or Java, or C if someone demanded I do it...)
https://gist.github.com/travisbhartwell/f972aab227306edfcfea
Yes, you have to install nix, but you _only_ have to install nix.