Reimplement pythondeps.sh as parametric macro generators
pythondeps.sh was written in shell and unlike the Python dist generators, it uses no Python, it plainly determines the provide / requires from the path. As the script was run for every Python file, we were potentially doing hundreds of shelling outs to execute a script that calls grep and sed. In Lua, this is much more efficient. Some timings: https://github.com/rpm-software-management/rpm/pull/1153#issuecomment-607146356 Parametric macro generators require RPM 4.16+: https://fedoraproject.org/wiki/Changes/RPM-4.16 Fixes https://github.com/rpm-software-management/rpm/issues/1152 Upstream PR: https://github.com/rpm-software-management/rpm/pull/1153 Since this is intended for Fedora 33+ only, clean some old cruft.
This commit is contained in:
parent
caccd3e498
commit
ff7b9b1ae0
@ -1,11 +1,7 @@
|
|||||||
# Disable automatic bytecompilation. We install only one script and we will
|
|
||||||
# never "import" it.
|
|
||||||
%undefine py_auto_byte_compile
|
|
||||||
|
|
||||||
Name: python-rpm-generators
|
Name: python-rpm-generators
|
||||||
Summary: Dependency generators for Python RPMs
|
Summary: Dependency generators for Python RPMs
|
||||||
Version: 10
|
Version: 11
|
||||||
Release: 4%{?dist}
|
Release: 1%{?dist}
|
||||||
|
|
||||||
# Originally all those files were part of RPM, so license is kept here
|
# Originally all those files were part of RPM, so license is kept here
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -14,8 +10,7 @@ Url: https://src.fedoraproject.org/python-rpm-generators
|
|||||||
Source0: https://raw.githubusercontent.com/rpm-software-management/rpm/102eab50b3d0d6546dfe082eac0ade21e6b3dbf1/COPYING
|
Source0: https://raw.githubusercontent.com/rpm-software-management/rpm/102eab50b3d0d6546dfe082eac0ade21e6b3dbf1/COPYING
|
||||||
Source1: python.attr
|
Source1: python.attr
|
||||||
Source2: pythondist.attr
|
Source2: pythondist.attr
|
||||||
Source3: pythondeps.sh
|
Source3: pythondistdeps.py
|
||||||
Source4: pythondistdeps.py
|
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -25,10 +20,8 @@ BuildArch: noarch
|
|||||||
%package -n python3-rpm-generators
|
%package -n python3-rpm-generators
|
||||||
Summary: %{summary}
|
Summary: %{summary}
|
||||||
Requires: python3-setuptools
|
Requires: python3-setuptools
|
||||||
# The point of split
|
# We have parametric macro generators, we need RPM 4.16 (4.15.90+ is 4.16 alpha)
|
||||||
Conflicts: rpm-build < 4.13.0.1-2
|
Requires: rpm > 4.15.90-0
|
||||||
# Breaking change, change a way how depgen is enabled
|
|
||||||
Conflicts: python-rpm-macros < 3-35
|
|
||||||
|
|
||||||
%description -n python3-rpm-generators
|
%description -n python3-rpm-generators
|
||||||
%{summary}.
|
%{summary}.
|
||||||
@ -39,16 +32,19 @@ cp -a %{sources} .
|
|||||||
|
|
||||||
%install
|
%install
|
||||||
install -Dpm0644 -t %{buildroot}%{_fileattrsdir} python.attr pythondist.attr
|
install -Dpm0644 -t %{buildroot}%{_fileattrsdir} python.attr pythondist.attr
|
||||||
install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} pythondeps.sh pythondistdeps.py
|
install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} pythondistdeps.py
|
||||||
|
|
||||||
%files -n python3-rpm-generators
|
%files -n python3-rpm-generators
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%{_fileattrsdir}/python.attr
|
%{_fileattrsdir}/python.attr
|
||||||
%{_fileattrsdir}/pythondist.attr
|
%{_fileattrsdir}/pythondist.attr
|
||||||
%{_rpmconfigdir}/pythondeps.sh
|
|
||||||
%{_rpmconfigdir}/pythondistdeps.py
|
%{_rpmconfigdir}/pythondistdeps.py
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Apr 01 2020 Miro Hrončok <mhroncok@redhat.com> - 11-1
|
||||||
|
- Rewrite python(abi) generators to Lua to make them faster
|
||||||
|
- RPM 4.16+ is needed
|
||||||
|
|
||||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 10-4
|
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 10-4
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
|
||||||
|
28
python.attr
28
python.attr
@ -1,4 +1,28 @@
|
|||||||
%__python_provides %{_rpmconfigdir}/pythondeps.sh --provides
|
%__python_provides() %{lua:
|
||||||
%__python_requires %{_rpmconfigdir}/pythondeps.sh --requires
|
-- Match buildroot/payload paths of the form
|
||||||
|
-- /PATH/OF/BUILDROOT/usr/bin/pythonMAJOR.MINOR
|
||||||
|
-- generating a line of the form
|
||||||
|
-- python(abi) = MAJOR.MINOR
|
||||||
|
-- (Don't match against -config tools e.g. /usr/bin/python2.6-config)
|
||||||
|
local path = rpm.expand('%1')
|
||||||
|
if path:match('/usr/bin/python%d+%.%d+$') then
|
||||||
|
provides = path:gsub('.*/usr/bin/python(%d+%.%d+)', 'python(abi) = %1')
|
||||||
|
print(provides)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
%__python_requires() %{lua:
|
||||||
|
-- Match buildroot paths of the form
|
||||||
|
-- /PATH/OF/BUILDROOT/usr/lib/pythonMAJOR.MINOR/ and
|
||||||
|
-- /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/
|
||||||
|
-- generating a line of the form:
|
||||||
|
-- python(abi) = MAJOR.MINOR
|
||||||
|
local path = rpm.expand('%1')
|
||||||
|
if path:match('/usr/lib%d*/python%d+%.%d+/.*') then
|
||||||
|
requires = path:gsub('.*/usr/lib%d*/python(%d+%.%d+)/.*', 'python(abi) = %1')
|
||||||
|
print(requires)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
%__python_path ^((/usr/lib(64)?/python[[:digit:]]\\.[[:digit:]]+/.*\\.(py[oc]?|so))|(^%{_bindir}/python[[:digit:]]\\.[[:digit:]]+))$
|
%__python_path ^((/usr/lib(64)?/python[[:digit:]]\\.[[:digit:]]+/.*\\.(py[oc]?|so))|(^%{_bindir}/python[[:digit:]]\\.[[:digit:]]+))$
|
||||||
%__python_magic [Pp]ython.*(executable|byte-compiled)
|
%__python_magic [Pp]ython.*(executable|byte-compiled)
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
[ $# -ge 1 ] || {
|
|
||||||
cat > /dev/null
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
-P|--provides)
|
|
||||||
shift
|
|
||||||
# Match buildroot/payload paths of the form
|
|
||||||
# /PATH/OF/BUILDROOT/usr/bin/pythonMAJOR.MINOR
|
|
||||||
# generating a line of the form
|
|
||||||
# python(abi) = MAJOR.MINOR
|
|
||||||
# (Don't match against -config tools e.g. /usr/bin/python2.6-config)
|
|
||||||
grep "/usr/bin/python.\..$" \
|
|
||||||
| sed -e "s|.*/usr/bin/python\(.\..\)|python(abi) = \1|"
|
|
||||||
;;
|
|
||||||
-R|--requires)
|
|
||||||
shift
|
|
||||||
# Match buildroot paths of the form
|
|
||||||
# /PATH/OF/BUILDROOT/usr/lib/pythonMAJOR.MINOR/ and
|
|
||||||
# /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/
|
|
||||||
# generating (uniqely) lines of the form:
|
|
||||||
# python(abi) = MAJOR.MINOR
|
|
||||||
grep "/usr/lib[^/]*/python.\../.*" \
|
|
||||||
| sed -e "s|.*/usr/lib[^/]*/python\(.\..\)/.*|python(abi) = \1|g" \
|
|
||||||
| sort | uniq
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
Loading…
Reference in New Issue
Block a user