python / python/cpython

After "make install" the __pycache__ directories are only readable by root

Open
#126,086 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

build topic-installation type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Building python on RHEL9 with

mkdir tmp; export TMPDIR=$(pwd)/tmp
tar xf /tmp/Python-3.11.10.tar.xz
cd Python-3.11.10/
./configure --enable-optimizations --with-lto
make -s -j
sudo make install

results in a usable python. However only root can read the __pycache__ files, example:

ls -l /usr/local/lib/python3.11/__pycache__

...
-rw-r-----. 1 root root 29675 Oct 28 18:26 zipimport.cpython-311.opt-1.pyc
-rw-r-----. 1 root root 25988 Oct 28 18:26 zipimport.cpython-311.opt-2.pyc
-rw-r-----. 1 root root 29793 Oct 28 18:26 zipimport.cpython-311.pyc

Note that the pycache folder itself is also only readable by root.

To fix this manually one can do

sudo find /usr/local -type d -name '__pycache__' -exec chmod -R a+rX {} \;

but I would have expected make install to do it.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the RHEL9 build using the configure, make, and sudo make install commands in the report, then trace how installation creates the pycache directories and files. Done means a non-root user can read the installed pycache directories and .pyc files without the manual chmod workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.