2019-01-25 22:55:51

by Russell Coker

[permalink] [raw]
Subject: __pycache__

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?

--
My Main Blog http://etbe.coker.com.au/
My Documents Blog http://doc.coker.com.au/





2019-01-26 02:49:58

by Chris PeBenito

[permalink] [raw]
Subject: Re: __pycache__

On 1/25/19 5:55 PM, Russell Coker wrote:
> 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

--
Chris PeBenito