diff --git a/README.md b/README.md index 04acf40..4b83779 100644 --- a/README.md +++ b/README.md @@ -133,9 +133,13 @@ in `%generate_buildrequires`. If not, you need to add: Limitations ----------- - -This macro changes shebang lines of every Python script in `%{buildroot}%{_bindir}` to `#! %{__python3} %{py3_shbang_opt}` (`#! /usr/bin/python3 -s`). -We plan to preserve existing Python flags in shebangs, but the work is not yet finished. +`%pyproject_install` 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. +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. diff --git a/macros.pyproject b/macros.pyproject index 056e76c..2d13729 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -9,7 +9,7 @@ CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\ %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 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__ fi if [ -d %{buildroot}%{python3_sitelib} ]; then diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 6997652..c3f65fd 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -90,6 +90,7 @@ install -m 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/ * Wed Feb 05 2020 Miro HronĨok - 0-12 - Fallback to setuptools.build_meta:__legacy__ backend instead of setuptools.build_meta - Properly handle backends with colon +- Preserve existing flags in shebangs of Python files in /usr/bin * Thu Jan 30 2020 Fedora Release Engineering - 0-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild diff --git a/tests/tldr.spec b/tests/tldr.spec index 0b76ffa..aa66812 100644 --- a/tests/tldr.spec +++ b/tests/tldr.spec @@ -27,6 +27,7 @@ BuildRequires: pyproject-rpm-macros %check test ! -d %{buildroot}%{_bindir}/__pycache__ +head -n1 %{buildroot}%{_bindir}/%{name}.py | egrep '#!\s*%{python3}\s+%{py3_shbang_opts}\s*$' %files %license LICENSE