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, or just placed in the current directory) 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 committed Apr 4, 2024
1 parent 9b2b2e8 commit ab22cb9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ ln -sr %{buildroot}%{confdir}/vars %{buildroot}%{_sysconfdir}/yum/vars
rm %{buildroot}%{confdir}/%{name}.conf
%endif

%if 0%{?fedora} >= 41 || 0%{?rhel} >= 10
%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 ab22cb9

Please sign in to comment.