On 11/17/19 8:39 AM, Pierre Labastie via blfs-dev wrote:
Le 17/11/2019 à 11:45, Wayne Blaszczyk via blfs-dev a écrit :
Hi All,

I have just noticed that with all my builds, there are __pycache__ directories
being installed all over the place.
As an example, when I installed totem, it created /usr/bin/__pycache__/ with a
bunch of files underneath it which are actual not related to totem.
I raised a bug but it was quickly dismissed.
https://gitlab.gnome.org/GNOME/totem/issues/375
I know that totem is not part of BLFS anymore, but there are other packages
creating the same sort thing.
Polkit for example has created files under 
/usr/lib/gobject-introspection/giscanner/__pycache__/
Has anyone else come across this? Is this expected?


I think it is expected: each time a python program is interpreted, it is
actually transformed to an intermediate binary (byte-compiled). Under certain
conditions, this binary is saved into the __pycache__directory, so that the
next time it is run, the binary is used, saving the time for byte-compiling.

There is also a python module for byte-compiling all the files in a directory 
[1].

As a specific example, gedit has a post_install.py script, which does
byte-compile all the python programs in /usr/lib/gedit/plugins. I think it is
the same for totem (although creating __pycache__ directly in /usr/bin should
be avoided, IMO).

Pierre

[1] https://docs.python.org/3/library/compileall.html


Checking my system, I find that directory in the following locations.

/usr/lib/peas-demo
/usr/lib/gobject-introspection/giscanner
/usr/lib/gedit/plugins
/usr/lib/python3.7
/usr/lib/python3.8
/usr/share/gdb/python
/usr/share/gtk-doc/python/gtkdoc

It's not common, but I wonder what happens if /usr is mounted read only. You would think that these files would be in a more conventional place line /var/cache.

I did a quick search but couldn't find anything about changing the cache location. I would think an environment variable or a configuration file could control this. The only python specific environment variables I could find are PYTHONPATH and PYTHONDONTWRITEBYTECODE.

I did find these:

https://stackoverflow.com/questions/3522079/changing-the-directory-where-pyc-files-are-created/57414308#57414308

https://stackoverflow.com/questions/16869024/what-is-pycache

  -- Bruce
--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to