forked from rpms/python-rpm-macros
Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Miro Hrončok | 24dc66a003 | |
Miro Hrončok | 3cce7271e4 |
|
@ -10,9 +10,11 @@
|
|||
%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_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_shbang_opts -s
|
||||
%_py_shebang_s s
|
||||
%py_shbang_opts -%{?_py_shebang_s}
|
||||
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_fix %{expand:\\\
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
%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_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}
|
||||
|
||||
%py3_shbang_opts -s
|
||||
%_py3_shebang_s s
|
||||
%py3_shbang_opts -%{?_py3_shebang_s}
|
||||
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_fix %{expand:\\\
|
||||
|
@ -103,6 +105,7 @@
|
|||
pyminor = path:match("/python3.(%d+)/") or "*"
|
||||
dirname = path:match("(.*/)")
|
||||
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")
|
||||
end
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ elseif posix.stat('macros.python-srpm') then
|
|||
end
|
||||
}
|
||||
Version: %{__default_python3_version}
|
||||
Release: 18%{?dist}
|
||||
Release: 19%{?dist}
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
|
@ -151,6 +151,10 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
|
|||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.10-19
|
||||
- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311
|
||||
- Define and use %%{_py3_shebang_s} in the shebang macros for easier opt-out
|
||||
|
||||
* Thu May 26 2022 Owen Taylor <otaylor@redhat.com> - 3.10-18
|
||||
- Support installing to %%{_prefix} other than /usr
|
||||
|
||||
|
|
|
@ -72,8 +72,17 @@ def get_alt_x_y():
|
|||
raise ValueError(f"${env_name} must be X.Y")
|
||||
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_xy = pytest.fixture(scope="session")(get_alt_xy)
|
||||
|
||||
|
||||
def shell_stdout(script):
|
||||
|
@ -409,6 +418,13 @@ def test_py3_shebang_fix_custom_shebang_flags():
|
|||
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'
|
||||
assert shell_stdout('\n'.join(lines)) == '-k'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('flags', [None, '%{nil}'])
|
||||
def test_py3_shebang_fix_no_shebang_flags(flags):
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', py3_shebang_flags=flags)
|
||||
|
@ -638,6 +654,7 @@ unversioned_macros = pytest.mark.parametrize('macro', [
|
|||
'%python_platform',
|
||||
'%python_platform_triplet',
|
||||
'%python_ext_suffix',
|
||||
'%python_cache_tag',
|
||||
'%py_shebang_fix',
|
||||
'%py_build',
|
||||
'%py_build_egg',
|
||||
|
@ -676,6 +693,18 @@ def test_ext_suffix():
|
|||
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():
|
||||
macro = '%python_sitelib'
|
||||
assert rpm_eval(macro, __python='%__python3') == [f'/usr/lib/python{X_Y}/site-packages']
|
||||
|
|
Loading…
Reference in New Issue