Deprecate %py3_build, %py3_build_wheel, and %py3_install
...as well as their %py_... counterparts. https://fedoraproject.org/wiki/Changes/DeprecateSetuppyMacros
This commit is contained in:
parent
6b1cf3771c
commit
b8a5807572
4 changed files with 62 additions and 8 deletions
|
|
@ -23,6 +23,23 @@ end
|
|||
print(_python_macro_cache[cache_key][name])
|
||||
}
|
||||
|
||||
# Deprecation wrapper, warns only once per macro
|
||||
# Options:
|
||||
# -n - The name of the macro that is deprecated
|
||||
%_python_deprecated(n:) %{lua:
|
||||
if not _python_deprecated_warned then
|
||||
-- This is intentionally a global lua table
|
||||
_python_deprecated_warned = {}
|
||||
end
|
||||
if not _python_deprecated_warned[opt.n] then
|
||||
_python_deprecated_warned[opt.n] = true
|
||||
local msg = "The %" .. opt.n .. " macro is deprecated and will likely stop working in Fedora 44. " ..
|
||||
"See the current Python packaging guidelines: " ..
|
||||
"https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/"
|
||||
macros.warn({msg})
|
||||
end
|
||||
}
|
||||
|
||||
# unversioned macros: used with user defined __python, no longer part of rpm >= 4.15
|
||||
# __python is defined to error by default in the srpm macros
|
||||
# nb: $RPM_BUILD_ROOT is not set when the macros are expanded (at spec parse time)
|
||||
|
|
@ -69,17 +86,17 @@ print(_python_macro_cache[cache_key][name])
|
|||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
%py_build() %{expand:\\\
|
||||
%py_build() %{_python_deprecated -n py_build}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py_shbang_opts}" %{?*}
|
||||
}
|
||||
|
||||
%py_build_wheel() %{expand:\\\
|
||||
%py_build_wheel() %{_python_deprecated -n py_build_wheel}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
||||
}
|
||||
|
||||
%py_install() %{expand:\\\
|
||||
%py_install() %{_python_deprecated -n py_install}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} --prefix %{_prefix} %{?*}
|
||||
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
||||
|
|
|
|||
|
|
@ -43,17 +43,17 @@
|
|||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
%py3_build() %{expand:\\\
|
||||
%py3_build() %{_python_deprecated -n py3_build}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}
|
||||
}
|
||||
|
||||
%py3_build_wheel() %{expand:\\\
|
||||
%py3_build_wheel() %{_python_deprecated -n py3_build_wheel}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
|
||||
}
|
||||
|
||||
%py3_install() %{expand:\\\
|
||||
%py3_install() %{_python_deprecated -n py3_install}%{expand:\\\
|
||||
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
|
||||
%{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} --prefix %{_prefix} %{?*}
|
||||
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ elseif posix.stat('macros.python-srpm') then
|
|||
end
|
||||
}
|
||||
Version: %{__default_python3_version}
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
|
|
@ -167,6 +167,11 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
|
|||
|
||||
|
||||
%changelog
|
||||
* Sun Jun 29 2025 Miro Hrončok <mhroncok@redhat.com> - 3.14-2
|
||||
- Deprecate %%py3_build, %%py3_build_wheel, and %%py3_install
|
||||
- Deprecate %%py_build, %%py_build_wheel, and %%py_install
|
||||
- https://fedoraproject.org/wiki/Changes/DeprecateSetuppyMacros
|
||||
|
||||
* Wed May 28 2025 Karolina Surma <ksurma@redhat.com> - 3.14-1
|
||||
- Update main Python to 3.14
|
||||
|
||||
|
|
|
|||
|
|
@ -760,6 +760,9 @@ unversioned_macros = pytest.mark.parametrize('macro', [
|
|||
@unversioned_macros
|
||||
def test_unversioned_python_errors(macro):
|
||||
lines = rpm_eval(macro, fails=True)
|
||||
# strip the deprecation message
|
||||
if 'deprecated' in lines[0]:
|
||||
lines = lines[1:]
|
||||
assert lines[0] == (
|
||||
'error: attempt to use unversioned python, '
|
||||
'define %__python to /usr/bin/python2 or /usr/bin/python3 explicitly'
|
||||
|
|
@ -777,7 +780,9 @@ def test_unversioned_python_errors(macro):
|
|||
@unversioned_macros
|
||||
def test_unversioned_python_works_when_defined(macro):
|
||||
macro3 = macro.replace('python', 'python3').replace('py_', 'py3_')
|
||||
assert rpm_eval(macro, __python='/usr/bin/python3') == rpm_eval(macro3)
|
||||
unverisoned = rpm_eval(macro, __python='/usr/bin/python3')
|
||||
expected = [l.replace(macro3, macro) for l in rpm_eval(macro3)]
|
||||
assert unverisoned == expected
|
||||
|
||||
|
||||
# we could rework the test for multiple architectures, but the Fedora CI currently only runs on x86_64
|
||||
|
|
@ -958,3 +963,30 @@ def test_multi_python3(alt_x_y):
|
|||
lines = rpm_eval(evals)
|
||||
lines = [l for l in lines if l] # strip empty lines generated by %global
|
||||
assert lines == [X_Y, alt_x_y, X_Y, X_Y]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('macro', [
|
||||
'%py3_build',
|
||||
'%py3_build_wheel',
|
||||
'%py3_install',
|
||||
])
|
||||
def test_deprecation(macro):
|
||||
lines = rpm_eval(macro)
|
||||
assert "is deprecated" in lines[0]
|
||||
assert f"{macro} " in lines[0]
|
||||
|
||||
|
||||
def test_multiple_deprecation():
|
||||
source = '%{py3_build}' * 10 + '%{py3_build_wheel}' * 10 + '%{py3_install}' * 10 + '%{py3_build}'
|
||||
lines = rpm_eval(source)
|
||||
|
||||
assert "is deprecated" in lines[0]
|
||||
assert "%py3_build " in lines[0]
|
||||
|
||||
assert "is deprecated" in lines[1]
|
||||
assert "%py3_build_wheel " in lines[1]
|
||||
|
||||
assert "is deprecated" in lines[2]
|
||||
assert "%py3_install " in lines[2]
|
||||
|
||||
assert "is deprecated" not in '\n'.join(lines[3:])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue