Hi,
I'd like to create .pyc files and create scripts that will still run only using .pyc files (for sharing the files).
important is that I would also like to use import modules I have created, so it should work to import pyc files or compile all files into one main pyc file.
can I get a short into in how to create those files?
please let me know.. thanks!
matt
if you need to try, 32.10. py_compile — Compile Python source files — Python 2.7.12 documentation
There are many references to this, just search .... create pyc python ... as a search phrase, e.g.
python - How can I manually generate a .pyc file from a .py file - Stack Overflow
import py_compile
py_compile.compile("file.py")
Ah nice.. so there's no specific steps in ArcPy, all standard Python stuff, right?
give it whirl with your code, I don't use pyc... the only advantage is for use in a situation where people are working in an environment that would restrict the compilation on their machine. If it for hiding/protecting your code, it will slow down most, but not guarantee it... for that produce a license agreement
Ok, thanks for the inputs, as always!
I'll try!
Matt
Report? did it work?
Hi,
Sorry, I've been out of town for work for 2 weeks .. and this week's been busy too.
But thanks for checking back.
The compiling part did work, yes. Though what I ended up using are the automatically generated .pyc files in the same folder. I am not sure why I did not see them being produced in the first place, this is puzzling. It may be a folder refresh issue.
So basically, the structure I'm using now is 1 py file and 1 pyc file, where in the first file I just call a method in the second file, passing on the relevant parameters / user settings.
Thanks !!
matt
pyc files are created when a file/module is created. It remains the same unless edits to the underlying script are made, just be aware that if you edit your script from which the pyc was created, that you need to use the new pyc
32.11. compileall — Byte-compile Python libraries — Python 2.7.12 documentation
But note that distributing pycs only won't stop people from being able to see your source code if they want to...
The benefits (and limitations) of PYC-only Python distribution | Curious Efficiency https://docs.python.org/2/library/compileall.html