diff --git a/python38-shebang-sanity.sh b/python38-shebang-sanity.sh new file mode 100644 index 0000000..4de6b65 --- /dev/null +++ b/python38-shebang-sanity.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -efu + +find "$RPM_BUILD_ROOT" -type f -print | while read -r line ; do + if file "$line" | grep -q ELF ; then continue ; fi + if head -n 1 "$line" | grep -qE '([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*.*python3' ; then + sed -i -e '1s,python3,python3.8,g' -e '1s,python3.8.8,python3.8,g' "$line" + sed -E -i "$line" \ + -e '1s,([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*/usr/bin/env([[:blank:]])*python3.8,#!/usr/libexec/python3.8,g' \ + -e '1s,([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*/usr/bin/python3.8,#!/usr/libexec/python3.8,g' + fi +done diff --git a/python38.macros b/python38.macros index d3f5bf5..0979a89 100644 --- a/python38.macros +++ b/python38.macros @@ -1,4 +1,5 @@ -%__python38 /usr/bin/python3.8 +%__python38 /usr/libexec/python3.8 + %python38_sitelib %(%{__python38} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python38_sitearch %(%{__python38} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %python38_version %(%{__python38} -c "import sys; print(sys.version[0:3])") @@ -23,3 +24,6 @@ CFLAGS="%{optflags}" %{__python38} %{py_setup} %{?py_setup_args} install -O1 --s %py38_test() %{expand:\ %{__python38} %{py_setup} %{?py_setup_args} test %{?1}\ } + +%py38_shebang_sanity %{_bindir}/python38-shebang-sanity +%py38_ss %py38_shebang_sanity diff --git a/python38.spec b/python38.spec index 563f757..28c5379 100644 --- a/python38.spec +++ b/python38.spec @@ -31,6 +31,9 @@ %define sub_ver %{familyver} %endif +# one dir for rpm4/5 +%global _libexecdir /usr/libexec + ########################################### # We want to byte-compile the .py files within the packages using the new @@ -51,7 +54,7 @@ Summary: An interpreted, interactive object-oriented programming language Name: %{py3_name} Version: 3.8.2 -Release: 4 +Release: 5 License: Modified CNRI Open Source License Group: Development/Python @@ -59,6 +62,7 @@ Source0: https://www.python.org/ftp/python/%{version}/Python-%{version}. Source1: https://docs.python.org/3/archives/python-%{docver}-docs-html.tar.bz2 Source2: python38.macros Source3: pybytecompile.macros +Source4: python38-shebang-sanity.sh Source100: python38.rpmlintrc # 00001 # @@ -406,10 +410,20 @@ ln -s python3-config %{buildroot}%{_bindir}/python-config # See https://github.com/fedora-python/python-rpm-porting/issues/24 cp -p Tools/scripts/pathfix.py %{buildroot}%{_bindir}/ -%if %{with py38} +%if %{with py38} + +install -m0755 %{SOURCE4} %{buildroot}%{_bindir}/python38-shebang-sanity + mv %{buildroot}%{_bindir}/pynche3 \ %{buildroot}%{_bindir}/pynche%{sub_ver} +# Build scripts of many packages try to use the highest version of Python that they find +# That is why we have to relocate python3.8 out of $PATH +mkdir -p %{buildroot}%{_libexecdir} +mv %{buildroot}%{_bindir}/python3.8 %{buildroot}%{_libexecdir}/python3.8 +# Temporary compat symlink untill all packages are fixed +( cd %{buildroot}%{_bindir} ; ln -s ../libexec/python3.8 python3.8 ) + # Remove shebang lines from .py files that aren't executable, and # remove executability from .py files that don't have a shebang line: find %{buildroot} -name \*.py \ @@ -419,13 +433,7 @@ find %{buildroot} -name \*.py \ -exec chmod a-x {} \; \) \) ########## shebang py3 > py3.8 ################## - -find %{buildroot} -type f -print | while read -r line ; do - if file "$line" | grep -q ELF ; then continue ; fi - if head -n 1 "$line" | grep -v python3.8 | grep -q python3 ; then - sed -i -e '1s,python3,python3.8,g' "$line" - fi -done +sh %{SOURCE4} # When packaging a not system version of Python, these files are named like e.g. 2to3-3.8 # These files must not be packaged to avoid conflicts with system python3 @@ -515,6 +523,9 @@ export TMP="/tmp" TMPDIR="/tmp" %if %{with valgrind} %{_libdir}/valgrind/valgrind-python3.supp %endif +%if %{with py38} +%{_libexecdir}/python3* +%endif %files -n %{lib_name} %{_libdir}/libpython*.so.1*