Skip to content

Commit

Permalink
Do not add user site-packages directory to sys.path (RHEL-26646)
Browse files Browse the repository at this point in the history
Adds `-s` to shebang lines.
The `-s` flag ensures that the user’s Python packages (e.g. installed by
pip install --user) don’t interfere with the RPM installed software.
According to Fedora Python Packaging Guidelines, the flag is added using
`%py3_shebang_fix` macro.

Note:
DNF supports plugins. There is a risk that the change will break
a custom plugins that require something from PIP.
Therefore, the change is only in the .spec file and is only allowed
for Fedora >= 41 and RHEL >= 10.
  • Loading branch information
jrohel authored and ppisar committed Apr 4, 2024
1 parent cb464d4 commit caa17e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dnf.spec
Expand Up @@ -256,6 +256,16 @@ rm %{buildroot}%{confdir}/%{name}.conf
rm %{buildroot}%{_mandir}/man5/%{name}.conf.5*
%endif

%if 0%{?fedora} >= 41 || 0%{?rhel} >= 10
# Don't add -P to Python shebangs
# The executable Python scripts import each other
%undefine _py3_shebang_P

%py3_shebang_fix %{buildroot}%{_bindir}/dnf-3
%py3_shebang_fix %{buildroot}%{_bindir}/dnf-automatic
%py3_shebang_fix %{buildroot}%{python3_sitelib}/%{name}/cli/completion_helper.py
%endif

%check

pushd build-py3
Expand Down

0 comments on commit caa17e3

Please sign in to comment.