Deploying pythonista scripts/bytecode to other users of pythonista
I am looking for a proven workflow to distribute a python script to others that run pythonista on IOS. Ideally I would like to only distribute .PYC compiled code without the underlying .PY source, if that is possible. I have successfully compiled my script using py_compile and it creates bytecode files in the cache. Now the question is how do you run it without the source?
will run it, if the myscript.py is present, not so much if it's missing and only the PYC is present. I did try with both settings for "sys.dont_write_bytecode" just in case that would also affect the loading behavior. Do I need to move the PYC file from the cache to the main directory?
Also, what's the best way to package it, so that other can unpackage it on their phones with copy/pasting source code etc.?
Thanks much for any help you can provide.
Don't do this. Pyc is not guaranteed to be compatible across versions, and unless you plan on maintaining your code, it will soon become useless.
Also, if you are hoping to hide your trade secrets, it won't work -- it is easy to decompile compiled bytecode back to readable python code.
In terms of how to package code -- gist is obviously the easiest, since it comes built into the app. Git is available in stash or the working copy app, and is another good way. A rarely used method is to create an executable url, which opens a script directly into the app. Some have made their modules available on pypi. You could also just zip the files up and place somewhere, with a one liner to install (see the stash GitHub repo for such an example)