Preserve existing flags in shebangs of Python files in /usr/bin
Use pathfix.py with -k and -a flags Solves problems like https://bugzilla.redhat.com/show_bug.cgi?id=1335203
This commit is contained in:
parent
6210f94e46
commit
dbb90f5dc1
10
README.md
10
README.md
@ -133,9 +133,13 @@ in `%generate_buildrequires`. If not, you need to add:
|
|||||||
Limitations
|
Limitations
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
`%pyproject_install` changes shebang lines of every Python script in `%{buildroot}%{_bindir}` to `#!%{__python3} %{py3_shbang_opt}` (`#!/usr/bin/python3 -s`).
|
||||||
This macro changes shebang lines of every Python script in `%{buildroot}%{_bindir}` to `#! %{__python3} %{py3_shbang_opt}` (`#! /usr/bin/python3 -s`).
|
Existing Python flags in shebangs are preserved.
|
||||||
We plan to preserve existing Python flags in shebangs, but the work is not yet finished.
|
For example `#!/usr/bin/python3 -Ru` will be updated to `#!/usr/bin/python3 -sRu`.
|
||||||
|
Sometimes, this can interfere with tests that run such scripts directly by name,
|
||||||
|
because in tests we usually rely on `PYTHONPATH` (and `-s` ignores that).
|
||||||
|
Would this behavior be undesired for any reason,
|
||||||
|
undefine `%{py3_shbang_opt}` to turn it of.
|
||||||
|
|
||||||
Extras are currently ignored.
|
Extras are currently ignored.
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
|
|||||||
%pyproject_install() %{expand:\\\
|
%pyproject_install() %{expand:\\\
|
||||||
%{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location %{_pyproject_wheeldir}/*.whl
|
%{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location %{_pyproject_wheeldir}/*.whl
|
||||||
if [ -d %{buildroot}%{_bindir} ]; then
|
if [ -d %{buildroot}%{_bindir} ]; then
|
||||||
pathfix.py -pni "%{__python3} %{py3_shbang_opts}" %{buildroot}%{_bindir}/*
|
pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/*
|
||||||
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
||||||
fi
|
fi
|
||||||
if [ -d %{buildroot}%{python3_sitelib} ]; then
|
if [ -d %{buildroot}%{python3_sitelib} ]; then
|
||||||
|
@ -90,6 +90,7 @@ install -m 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/
|
|||||||
* Wed Feb 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-12
|
* Wed Feb 05 2020 Miro Hrončok <mhroncok@redhat.com> - 0-12
|
||||||
- Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta
|
- Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta
|
||||||
- Properly handle backends with colon
|
- Properly handle backends with colon
|
||||||
|
- Preserve existing flags in shebangs of Python files in /usr/bin
|
||||||
|
|
||||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0-11
|
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0-11
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
@ -27,6 +27,7 @@ BuildRequires: pyproject-rpm-macros
|
|||||||
|
|
||||||
%check
|
%check
|
||||||
test ! -d %{buildroot}%{_bindir}/__pycache__
|
test ! -d %{buildroot}%{_bindir}/__pycache__
|
||||||
|
head -n1 %{buildroot}%{_bindir}/%{name}.py | egrep '#!\s*%{python3}\s+%{py3_shbang_opts}\s*$'
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
|
Loading…
Reference in New Issue
Block a user