4 ms·
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 h
by scrame 5y ago
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.
- nsomaru 5y agoI’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.
- scrame 5y agoThanks 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.
- VectorLock 5y agoI'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.
- scrame 5y agoThanks 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.
- GOATS- 5y agoYou can produce binaries for macOS and Linux with PyInstaller.
- cricalix 5y agoThere’s https://github.com/facebookincubator/xar https://github.com/facebookincubator/xar - but cross platform could be a pain. Basically static link “binary” for Python (or other).
- VectorLock 5y agoLooks 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).
- cricalix 5y agoYeah. Depends on your use case I suppose. If you’re after cross platform or non-Linux, then it’s not an answer.