Skip to contentSkip to conversation

__pycache__

DISCUSSION Russell Coker 2 participants 2 messages Jan 25, 2019 – Jan 26, 2019

lore
Share & tools
lore
#0 lore raw

type=AVC msg=audit(1548301606.546:586): avc: denied { write } for pid=8055 comm="semanage" name="__pycache__" dev="vda" ino=147333 scontext=unconfined_u:unconfined_r:semanage_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:lib_t:s0 tclass=dir permissive=0

What can we do about these __pycache__ write attempts? Is there something the distribution should be doing in terms of automatically generating those cache files when packages are installed?

Signature · 2 lines
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/
#1 lore raw
Quoted 8 lines · Russell Coker

type=AVC msg=audit(1548301606.546:586): avc: denied { write } for pid=8055 comm="semanage" name="__pycache__" dev="vda" ino=147333 scontext=unconfined_u:unconfined_r:semanage_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:lib_t:s0 tclass=dir permissive=0

What can we do about these __pycache__ write attempts? Is there something the distribution should be doing in terms of automatically generating those cache files when packages are installed?

It is possible to precompile the bytecode (Gentoo does this).

python -m py_compile file1.py file2.py ...

or recursively do all .py files:

python -m compileall /path/to/files

If you wanted, you could disable writing the bytecode by adding -B to the python command, though that's probably not what distros want to do.

https://docs.python.org/3/library/py_compile.html
https://docs.python.org/3/library/compileall.html

Signature · 1 line
Chris PeBenito