Obscuring Python source from end users
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Oct 2 03:22:48 EDT 2014
Marko Rauhamaa wrote:
> Dan Stromberg <drsalists at gmail.com>:
>
>> On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano
>>> Yes. Distribute the pyc files only.
>>
>> Yes, this is the way it's usually done.
>
> Has the .pyc file format stabilized? A decade ago, my employer shipped
> an application as .pyc files but had to ship the matching CPython binary
> with it.
There is no promise that Python byte code or the format of .pyc files will
be stable across minor releases. However, PEP 6 states that bugfix releases
should have stable .pyc files.
http://legacy.python.org/dev/peps/pep-0006/
So, you ought to expect that .pyc files will change when any of the
following differs:
- the hardware (e.g. 32- versus 64-bit, or ARM versus x86 processor);
- the Python implementation (e.g. Stackless versus CPython);
- the minor or major version number (e.g. 2.6 to 2.7, or 2.x to 3.x);
but you can expect the .pyc files to remain compatible for:
- the operating system (e.g. Windows, Mac, Linux);
- bug-release versions (e.g. 2.7.1 to 2.7.2).
Of course, you can distribute the Python executable, but it may be easier to
just distribute a separate .pyc file for each minor release you wish to
support.
Here are some comments from one of the senior core developers:
http://www.curiousefficiency.org/posts/2011/04/benefits-and-limitations-of-pyc-only.html
--
Steven
More information about the Python-list
mailing list