News for hackers. Stuff that matters.
Re:Make Your Python CLI Tools Pop with Rich by scrame on Friday January 21, 2022 @01:23AM (#30019881)
So what's the best way to pack up a python cli app in a single artifact?

Right now I have an interactive python script that wraps a bunch of config files and has a few pip dependencies. currently i batch it in a docker container which is pretty heavyweight, and realistically needs its own wrapper script for users.

If there was an unfussy way to wrap that as a single artifact I'd look into making the whole thing python.

Re:Make Your Python CLI Tools Pop with Rich by nsomaru on Friday January 21, 2022 @01:26AM (#30019899)
I’ve used pyinstaller with some success to do what you’ve described. It does end up bundling an entire Python runtime but it worked for me.

Nuitka is another option I haven’t tried.

Re:Make Your Python CLI Tools Pop with Rich by scrame on Friday January 21, 2022 @01:47AM (#30020047)
Thanks for the response. I understand pythons popularity especially with the "batteries included" philosophy, but when it runs out of batteries the headaches can multiply quickly.

I'll check out pyinstaller and nuitka.

Re:Make Your Python CLI Tools Pop with Rich by VectorLock on Friday January 21, 2022 @01:32AM (#30019949)
I've seen .EXE builders for Python that produce binaries for Windows, it'd be cool to have something similar in the *nix world.

Been seeing a lot of people who think Go is just better because you can build a single binary. Go is a pretty decent language but its weird that one feature seems to trump everything to far too many people I know.

Re:Make Your Python CLI Tools Pop with Rich by scrame on Friday January 21, 2022 @01:45AM (#30020030)
Thanks for the response. I was thinking something similar. This particular cli is a client to an app i wrote in kotlin/java that tracks particular kubernetes pods.

There were a ton of hoops to jump through on both sides and then someone asked why I didn't just write it in go.

Well, this was consolidating some other functionality on both sides and I was extending/migrating the apps as we moved from colo to cloud, and it just... didn't occur to me, and we don't really have anything golang based, so no expertise or infrastructure and the migrations were happening regardless.

In hindsight this might have been better done that way, but I don't know that I've got the bandwidth to rewrite it all.

Distributing a shell runscript to run a docker image works because everyone in my space uses docker, and most of the teams are single language focused and most aren't python.

Its still an issue to keep everyone's run script updated, but maybe not enough to introduce a new language and toolchain.

Re:Make Your Python CLI Tools Pop with Rich by GOATS- on Friday January 21, 2022 @08:51AM (#30023428)
You can produce binaries for macOS and Linux with PyInstaller.
Re:Make Your Python CLI Tools Pop with Rich by cricalix on Friday January 21, 2022 @03:45AM (#30020854)
There’s https://github.com/facebookincubator/xar - but cross platform could be a pain. Basically static link “binary” for Python (or other).
Re:Make Your Python CLI Tools Pop with Rich by VectorLock on Friday January 21, 2022 @09:48AM (#30024185)
Looks cool despite being a facebook thing but hit this mammoth caveat:

>This requires a one-time installation of a driver for this file system (SquashFS).

Re:Make Your Python CLI Tools Pop with Rich by cricalix on Friday January 21, 2022 @03:06PM (#30029249)
Yeah. Depends on your use case I suppose. If you’re after cross platform or non-Linux, then it’s not an answer.