From 8aa5298a68cda8a6705dbc1ae0fc85df2e66bf44 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Wed, 3 Apr 2024 14:05:23 +0200 Subject: [PATCH] Do not add user site-packages directory to sys.path (RHEL-26646) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_flags}` 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. --- dnf.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dnf.spec b/dnf.spec index 85e3d6c7dc..0130eeb431 100644 --- a/dnf.spec +++ b/dnf.spec @@ -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