strong-dawn-11939
07/11/2024, 11:21 PM...soon add support in Pants for building scies out of your code, which will allow you to package and ship fully standalone Python binaries!
wide-midnight-78598
07/11/2024, 11:49 PMwide-midnight-78598
07/11/2024, 11:50 PMwide-midnight-78598
07/11/2024, 11:52 PMstrong-dawn-11939
07/11/2024, 11:59 PMscie
but ultimately think it's a bit beyond me. So, I'm actually not fully certain I understand the nuance...would the one file that results from the scie_binary
target expected to be executable on major, up-to-date operating systems (macos, ubuntu, windows; assuming platforms
is set accordingly)? Are there implicit dependencies on other tools/programs that absolutely must exist on the target host for the scie
to execute?wide-midnight-78598
07/12/2024, 12:30 AMpantsible
, that's ansible put into an executable pex file (not a requirement, just makes my life easier), merged with Python Build Standalone (https://github.com/indygreg/python-build-standalone) for the Python interpreter, and then a small shim that orchestrates the unzipping, and calls, and whatnot (there is also a JSON manifest which contains the instructions on how everything interacts)
So, I get an executable file, that I can copy, put in my path, whatever. Upon execution, based on the instructions I gave it, it knows to download Python 3.12 and store that in cache, and then to unpack and pre-compile ansible into a venv, and then it knows what commands to call on my ansible venv
I can't say for certain if there are specific tools/programs, but I think it would be at the level of... glibc or musl or whatever - but I think the shimmed scie code otherwise runs standalone. I haven't looked into whether the stuff that needs to be on the OS is due to Python, or scie - to be honest.
Assuming you're running on mac or linux, if you setup your platforms accordingly, you should be good to go. In my case, I'm using a pex, and pex doesn't run on Windows
What's your use case?wide-midnight-78598
07/12/2024, 12:32 AMstrong-dawn-11939
07/12/2024, 12:55 AMpantsible
works for me (and is a cool idea)! I think this is starting to click. So: the pex
is installed in a venv, in a Python interpreter that is downloaded from Python Build Standalone on first run, and arg0 given to the scie
is mapped to an executable exposed by the pex
(which are really just binary scripts in the venv; venv/bin/...
).
In my case, I'm using a pex, and pex doesn't run on WindowsHm, yeah, interesting. I'd love to build a windows distribute-able binary as well, in addition to linux and mac.
What's your use case?The general use case is a CLI application for a SaaS data platform (https://www.roboto.ai/). Our customers use all three platforms (linux, macos, windows). I've put some effort into producing a standalone binary with PyInstaller (I saw a reference in the Pants Github issues history to an attempted
pyinstaller_binary
Pants target a while back...), but using PyInstaller complicates our CI, and the cold-start times of a PyInstaller binary on macOS is atrocious until we code sign the artifact.strong-dawn-11939
07/12/2024, 1:04 AMpex
? Or is there in-progress work towards its support? If Windows support isn't in the works or forthcoming, would it be simple to use something like https://shiv.readthedocs.io/en/latest/ instead of pex?wide-midnight-78598
07/12/2024, 1:24 AMSCIE_BOOT=migrate ./apigateway
type of thing - so multiple commands.
It’s been a long time since I’ve used anything but pex, so I can’t speak to shiv. I haven’t given it much thought - but maybe you can even just use “loose” python files that are unrelatedly packages (zipped or tarred or something). In the scie
plugin, I specifically used pex because it’s built into pants and I’ve used them so much otherwise, but I can’t really suggest that it’s a requirement per se.
I’m being a bit vague, because normally I would sanity test something on my machine before giving it a yay or nay, but I’m not near my machine at the moment. Otherwise, I’d probably try to whip something up with a custom scie that points the interpreter to a main.py and see what happens (entirely outside of pants for the sanity).
If you look at the docs, examples, and tests on a-scie/Lift or Jump - you can see some other reference examples - like using cat
to create a scie, or using node. To me that would imply that using other packaging mechanisms would workwide-midnight-78598
07/12/2024, 1:26 AMstrong-dawn-11939
07/12/2024, 7:39 AMwide-midnight-78598
07/17/2024, 1:10 AMpantisble
where I added the busybox functionality and stuff)strong-dawn-11939
07/17/2024, 3:11 PMwide-midnight-78598
07/17/2024, 3:37 PMwide-midnight-78598
07/17/2024, 3:38 PMstrong-dawn-11939
07/17/2024, 5:28 PMBut that doesn't feel right either - so maybe just a regular scie_target that internally decides what it wants to doUnderstanding only a fraction of this, assuming
pex --scie ...
produces the same type of output as scie_target
, then, I'd agree with this!