[Scons-users] Single binary SCons and byte-code caching

Mats Wichmann mats at wichmann.us
Thu Mar 10 16:31:55 EST 2022


On 3/10/22 13:25, Brad Kraemer wrote:
> Hello,
> 
> I'm not very well versed in the Python ecosystem, but did note that
> their seem to be several projects which allow for a Python application
> to be packaged into a single binary (ELF or PE). Has anyone tried to do
> this with SCons? Perhaps not entirely self-contained (in the static
> sense) but at least a single launch point (where no pre-existing Python
> installation is present).

pyinstaller can pretty much do this. might need some work - there's a
hook mechanism you use to teach it about things it can't detect itself,
and some of the dynamic stuff scons does - umm, Tool importing in
particular comes to mind - might defeat it. That's just guessing, never
tried it.

> Somewhat related I've noticed Python byte-code spawning in my Tools
> directories. I realize there is a benefit to this byte-code being cached
> ahead of time, but this does feel like a implementation-from-design
> leak. As a workaround, I can (Python 3.3+) set the environment variable
> PYTHONPYCACHEPREFIX to a better location which isn't within my Tools
> directories. As I look at this as a work around, I'm wondering if this
> couldn't be set by SCons itself when starting up (or equivalent Python
> functionality/variables)?

That's on behalf of the Python import system - keeping the bytecode
together with the source file (thankfully with Python 3 we at least get
a subdirectory) keeps the logic natural - if you find the .pyc there you
don't have to first compile the .py, but you don't want to go hunting
all over the place in the normal case.



More information about the Scons-users mailing list