Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8847b3750a | ||
|
4abed5f105 | ||
|
4d31ea8034 | ||
|
4085ef49f2 | ||
|
b8b5cb92da |
@ -10,9 +10,12 @@
|
|||||||
%python_platform %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_platform())")
|
%python_platform %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_platform())")
|
||||||
%python_platform_triplet %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
%python_platform_triplet %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
||||||
%python_ext_suffix %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
%python_ext_suffix %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
||||||
|
%python_cache_tag %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print(sys.implementation.cache_tag)")
|
||||||
|
|
||||||
%py_setup setup.py
|
%py_setup setup.py
|
||||||
%py_shbang_opts -s
|
%_py_shebang_s s
|
||||||
|
%_py_shebang_P %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||||
|
%py_shbang_opts -%{?_py_shebang_s}%{?_py_shebang_P}
|
||||||
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||||
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||||
%py_shebang_fix %{expand:\\\
|
%py_shebang_fix %{expand:\\\
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# There are two macros:
|
# There are two macros:
|
||||||
#
|
#
|
||||||
# This always contains the major.minor version (with dots), default for %%python3_version.
|
# This always contains the major.minor version (with dots), default for %%python3_version.
|
||||||
%__default_python3_version 3.10
|
%__default_python3_version 3.11
|
||||||
#
|
#
|
||||||
# The pkgname version that determines the alternative provide name (e.g. python3.9-foo),
|
# The pkgname version that determines the alternative provide name (e.g. python3.9-foo),
|
||||||
# set to the same as above, but historically hasn't included the dot.
|
# set to the same as above, but historically hasn't included the dot.
|
||||||
|
@ -8,9 +8,12 @@
|
|||||||
%python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
|
%python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
|
||||||
%python3_platform_triplet %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
%python3_platform_triplet %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
|
||||||
%python3_ext_suffix %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
%python3_ext_suffix %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
|
||||||
|
%python3_cache_tag %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print(sys.implementation.cache_tag)")
|
||||||
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
|
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
|
||||||
|
|
||||||
%py3_shbang_opts -s
|
%_py3_shebang_s s
|
||||||
|
%_py3_shebang_P %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||||
|
%py3_shbang_opts -%{?_py3_shebang_s}%{?_py3_shebang_P}
|
||||||
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||||
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||||
%py3_shebang_fix %{expand:\\\
|
%py3_shebang_fix %{expand:\\\
|
||||||
@ -103,6 +106,7 @@
|
|||||||
pyminor = path:match("/python3.(%d+)/") or "*"
|
pyminor = path:match("/python3.(%d+)/") or "*"
|
||||||
dirname = path:match("(.*/)")
|
dirname = path:match("(.*/)")
|
||||||
modulename = path:match(".*/([^/]+).py")
|
modulename = path:match(".*/([^/]+).py")
|
||||||
|
-- %%python3_cache_tag is not used here because this macro supports not-installed CPythons
|
||||||
print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
|
print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ elseif posix.stat('macros.python-srpm') then
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
Version: %{__default_python3_version}
|
Version: %{__default_python3_version}
|
||||||
Release: 18%{?dist}
|
Release: 4%{?dist}
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -151,6 +151,21 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.10-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jul 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-3
|
||||||
|
- Add "P" to %%py3_shbang_opts, %%py3_shbang_opts_nodash, %%py3_shebang_flags
|
||||||
|
and to %%py_shbang_opts, %%py_shbang_opts_nodash, %%py_shebang_flags
|
||||||
|
- https://fedoraproject.org/wiki/Changes/PythonSafePath
|
||||||
|
|
||||||
|
* Mon Jun 20 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-2
|
||||||
|
- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311
|
||||||
|
|
||||||
|
* Mon Jun 13 2022 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.11-1
|
||||||
|
- Update main Python to Python 3.11
|
||||||
|
- https://fedoraproject.org/wiki/Changes/Python3.11
|
||||||
|
|
||||||
* Thu May 26 2022 Owen Taylor <otaylor@redhat.com> - 3.10-18
|
* Thu May 26 2022 Owen Taylor <otaylor@redhat.com> - 3.10-18
|
||||||
- Support installing to %%{_prefix} other than /usr
|
- Support installing to %%{_prefix} other than /usr
|
||||||
|
|
||||||
|
@ -72,8 +72,22 @@ def get_alt_x_y():
|
|||||||
raise ValueError(f"${env_name} must be X.Y")
|
raise ValueError(f"${env_name} must be X.Y")
|
||||||
return alternate_python_version
|
return alternate_python_version
|
||||||
|
|
||||||
# We don't use the decorator, to be able to call the function itselef
|
|
||||||
|
def get_alt_xy():
|
||||||
|
"""
|
||||||
|
Same as get_alt_x_y() but without a dot
|
||||||
|
"""
|
||||||
|
return get_alt_x_y().replace(".", "")
|
||||||
|
|
||||||
|
|
||||||
|
# We don't use decorators, to be able to call the functions directly
|
||||||
alt_x_y = pytest.fixture(scope="session")(get_alt_x_y)
|
alt_x_y = pytest.fixture(scope="session")(get_alt_x_y)
|
||||||
|
alt_xy = pytest.fixture(scope="session")(get_alt_xy)
|
||||||
|
|
||||||
|
|
||||||
|
# https://fedoraproject.org/wiki/Changes/PythonSafePath
|
||||||
|
def safe_path_flag(x_y):
|
||||||
|
return 'P' if tuple(int(i) for i in x_y.split('.')) >= (3, 11) else ''
|
||||||
|
|
||||||
|
|
||||||
def shell_stdout(script):
|
def shell_stdout(script):
|
||||||
@ -400,7 +414,7 @@ def test_py3_shebang_fix():
|
|||||||
def test_py3_shebang_fix_default_shebang_flags():
|
def test_py3_shebang_fix_default_shebang_flags():
|
||||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2')
|
lines = rpm_eval('%py3_shebang_fix arg1 arg2')
|
||||||
lines[-1] = 'echo $shebang_flags'
|
lines[-1] = 'echo $shebang_flags'
|
||||||
assert shell_stdout('\n'.join(lines)) == '-kas'
|
assert shell_stdout('\n'.join(lines)) == f'-kas{safe_path_flag(X_Y)}'
|
||||||
|
|
||||||
|
|
||||||
def test_py3_shebang_fix_custom_shebang_flags():
|
def test_py3_shebang_fix_custom_shebang_flags():
|
||||||
@ -409,6 +423,31 @@ def test_py3_shebang_fix_custom_shebang_flags():
|
|||||||
assert shell_stdout('\n'.join(lines)) == '-kaEs'
|
assert shell_stdout('\n'.join(lines)) == '-kaEs'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('_py3_shebang_s', [None, '%{nil}'])
|
||||||
|
def test_py3_shebang_fix_undefined_py3_shebang_s(_py3_shebang_s):
|
||||||
|
lines = rpm_eval('%py3_shebang_fix arg1 arg2', _py3_shebang_s=_py3_shebang_s)
|
||||||
|
lines[-1] = 'echo $shebang_flags'
|
||||||
|
expected = f'-ka{safe_path_flag(X_Y)}' if safe_path_flag(X_Y) else '-k'
|
||||||
|
assert shell_stdout('\n'.join(lines)) == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('_py3_shebang_P', [None, '%{nil}'])
|
||||||
|
def test_py3_shebang_fix_undefined_py3_shebang_P(_py3_shebang_P):
|
||||||
|
lines = rpm_eval('%py3_shebang_fix arg1 arg2', _py3_shebang_P=_py3_shebang_P)
|
||||||
|
lines[-1] = 'echo $shebang_flags'
|
||||||
|
assert shell_stdout('\n'.join(lines)) == '-kas'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('_py3_shebang_s', [None, '%{nil}'])
|
||||||
|
@pytest.mark.parametrize('_py3_shebang_P', [None, '%{nil}'])
|
||||||
|
def test_py3_shebang_fix_undefined_py3_shebang_sP(_py3_shebang_s, _py3_shebang_P):
|
||||||
|
lines = rpm_eval('%py3_shebang_fix arg1 arg2',
|
||||||
|
_py3_shebang_s=_py3_shebang_s,
|
||||||
|
_py3_shebang_P=_py3_shebang_P)
|
||||||
|
lines[-1] = 'echo $shebang_flags'
|
||||||
|
assert shell_stdout('\n'.join(lines)) == '-k'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('flags', [None, '%{nil}'])
|
@pytest.mark.parametrize('flags', [None, '%{nil}'])
|
||||||
def test_py3_shebang_fix_no_shebang_flags(flags):
|
def test_py3_shebang_fix_no_shebang_flags(flags):
|
||||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', py3_shebang_flags=flags)
|
lines = rpm_eval('%py3_shebang_fix arg1 arg2', py3_shebang_flags=flags)
|
||||||
@ -638,6 +677,7 @@ unversioned_macros = pytest.mark.parametrize('macro', [
|
|||||||
'%python_platform',
|
'%python_platform',
|
||||||
'%python_platform_triplet',
|
'%python_platform_triplet',
|
||||||
'%python_ext_suffix',
|
'%python_ext_suffix',
|
||||||
|
'%python_cache_tag',
|
||||||
'%py_shebang_fix',
|
'%py_shebang_fix',
|
||||||
'%py_build',
|
'%py_build',
|
||||||
'%py_build_egg',
|
'%py_build_egg',
|
||||||
@ -676,6 +716,18 @@ def test_ext_suffix():
|
|||||||
assert rpm_eval("%python3_ext_suffix") == [f".cpython-{XY}-x86_64-linux-gnu.so"]
|
assert rpm_eval("%python3_ext_suffix") == [f".cpython-{XY}-x86_64-linux-gnu.so"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_cache_tag():
|
||||||
|
assert rpm_eval("%python3_cache_tag") == [f"cpython-{XY}"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_cache_tag_alternate_python(alt_x_y, alt_xy):
|
||||||
|
assert rpm_eval("%python_cache_tag", __python=f"/usr/bin/python{alt_x_y}") == [f"cpython-{alt_xy}"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_cache_tag_alternate_python3(alt_x_y, alt_xy):
|
||||||
|
assert rpm_eval("%python3_cache_tag", __python3=f"/usr/bin/python{alt_x_y}") == [f"cpython-{alt_xy}"]
|
||||||
|
|
||||||
|
|
||||||
def test_python_sitelib_value_python3():
|
def test_python_sitelib_value_python3():
|
||||||
macro = '%python_sitelib'
|
macro = '%python_sitelib'
|
||||||
assert rpm_eval(macro, __python='%__python3') == [f'/usr/lib/python{X_Y}/site-packages']
|
assert rpm_eval(macro, __python='%__python3') == [f'/usr/lib/python{X_Y}/site-packages']
|
||||||
@ -751,7 +803,6 @@ def test_py3_check_import(args, expected_args, __python3, lib):
|
|||||||
macros = {
|
macros = {
|
||||||
'buildroot': 'BUILDROOT',
|
'buildroot': 'BUILDROOT',
|
||||||
'_rpmconfigdir': 'RPMCONFIGDIR',
|
'_rpmconfigdir': 'RPMCONFIGDIR',
|
||||||
'py3_shebang_flags': 's',
|
|
||||||
}
|
}
|
||||||
if __python3 is not None:
|
if __python3 is not None:
|
||||||
if 'X.Y' in __python3:
|
if 'X.Y' in __python3:
|
||||||
@ -776,7 +827,7 @@ def test_py3_check_import(args, expected_args, __python3, lib):
|
|||||||
PYTHONPATH="${{PYTHONPATH:-BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages}}"
|
PYTHONPATH="${{PYTHONPATH:-BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages}}"
|
||||||
_PYTHONSITE="BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages"
|
_PYTHONSITE="BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages"
|
||||||
PYTHONDONTWRITEBYTECODE=1
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
{__python3 or '/usr/bin/python3'} -s RPMCONFIGDIR/redhat/import_all_modules.py {expected_args}
|
{__python3 or '/usr/bin/python3'} -s{safe_path_flag(x_y)} RPMCONFIGDIR/redhat/import_all_modules.py {expected_args}
|
||||||
""")
|
""")
|
||||||
assert lines == expected.splitlines()
|
assert lines == expected.splitlines()
|
||||||
|
|
||||||
@ -784,6 +835,7 @@ def test_py3_check_import(args, expected_args, __python3, lib):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'shebang_flags_value, expected_shebang_flags',
|
'shebang_flags_value, expected_shebang_flags',
|
||||||
[
|
[
|
||||||
|
('sP', '-sP'),
|
||||||
('s', '-s'),
|
('s', '-s'),
|
||||||
('%{nil}', ''),
|
('%{nil}', ''),
|
||||||
(None, ''),
|
(None, ''),
|
||||||
|
Loading…
Reference in New Issue
Block a user