Merged update from upstream sources
This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/python-rpm-macros.git#e5429a7a486e470b514aed207457fb237d061598
This commit is contained in:
parent
365a69534a
commit
ede6a5b9bf
@ -19,7 +19,12 @@
|
||||
# older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly
|
||||
pathfix=/usr/bin/pathfix.py
|
||||
fi
|
||||
$pathfix -pni %{__python} -k%{?py_shebang_flags:a %py_shebang_flags}}
|
||||
if [ -z "%{?py_shebang_flags}" ]; then
|
||||
shebang_flags="-k"
|
||||
else
|
||||
shebang_flags="-ka%{py_shebang_flags}"
|
||||
fi
|
||||
$pathfix -pni %{__python} $shebang_flags}
|
||||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
|
@ -7,7 +7,13 @@
|
||||
%py2_shbang_opts -s
|
||||
%py2_shbang_opts_nodash %(opts=%{py2_shbang_opts}; echo ${opts#-})
|
||||
%py2_shebang_flags %(opts=%{py2_shbang_opts}; echo ${opts#-})
|
||||
%py2_shebang_fix %{expand:/usr/bin/pathfix.py -pni %{__python2} -k%{?py2_shebang_flags:a %py2_shebang_flags}}
|
||||
%py2_shebang_fix %{expand:\\\
|
||||
if [ -z "%{?py_shebang_flags}" ]; then
|
||||
shebang_flags="-k"
|
||||
else
|
||||
shebang_flags="-ka%{py2_shebang_flags}"
|
||||
fi
|
||||
/usr/bin/pathfix.py -pni %{__python2} $shebang_flags}
|
||||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
|
@ -17,7 +17,12 @@
|
||||
# older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly
|
||||
pathfix=/usr/bin/pathfix.py
|
||||
fi
|
||||
$pathfix -pni %{__python3} -k%{?py3_shebang_flags:a %py3_shebang_flags}}
|
||||
if [ -z "%{?py3_shebang_flags}" ]; then
|
||||
shebang_flags="-k"
|
||||
else
|
||||
shebang_flags="-ka%{py3_shebang_flags}"
|
||||
fi
|
||||
$pathfix -pni %{__python3} $shebang_flags}
|
||||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: python-rpm-macros
|
||||
Version: 3.9
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
Summary: The common Python RPM macros
|
||||
|
||||
# macros and lua: MIT, compileall2.py: PSFv2
|
||||
@ -107,6 +107,9 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Dec 08 2020 Miro Hrončok <mhroncok@redhat.com> - 3.9-11
|
||||
- Support defining %%py3_shebang_flags to %%nil
|
||||
|
||||
* Mon Sep 14 2020 Miro Hrončok <mhroncok@redhat.com> - 3.9-10
|
||||
- Add %%python3_platform_triplet and %%python3_ext_suffix
|
||||
- https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names
|
||||
|
@ -42,6 +42,13 @@ def rpm_eval(expression, fails=False, **kwargs):
|
||||
return cp.stdout.strip().splitlines()
|
||||
|
||||
|
||||
def shell_stdout(script):
|
||||
return subprocess.check_output(script,
|
||||
env={**os.environ, 'LANG': 'C.utf-8'},
|
||||
text=True,
|
||||
shell=True).rstrip()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('argument, result', [
|
||||
('a', 'a'),
|
||||
('a-a', 'a-a'),
|
||||
@ -252,22 +259,31 @@ def test_pypi_source_explicit_tilde():
|
||||
|
||||
def test_py3_shebang_fix():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -ka s arg1 arg2 arg3'
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 $shebang_flags arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_py3_shebang_fix_custom_flags():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags='Es')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -ka Es arg1 arg2 arg3'
|
||||
def test_py3_shebang_fix_default_shebang_flags():
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2')
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
assert shell_stdout('\n'.join(lines)) == '-kas'
|
||||
|
||||
|
||||
def test_py3_shebang_fix_empty_flags():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags=None)[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -k arg1 arg2 arg3'
|
||||
def test_py3_shebang_fix_custom_shebang_flags():
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', py3_shebang_flags='Es')
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
assert shell_stdout('\n'.join(lines)) == '-kaEs'
|
||||
|
||||
|
||||
def test_py_shebang_fix_custom():
|
||||
@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)
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
assert shell_stdout('\n'.join(lines)) == '-k'
|
||||
|
||||
|
||||
def test_py_shebang_fix_custom_python():
|
||||
cmd = rpm_eval('%py_shebang_fix arg1 arg2 arg3', __python='/usr/bin/pypy')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/pypy -ka s arg1 arg2 arg3'
|
||||
assert cmd == '$pathfix -pni /usr/bin/pypy $shebang_flags arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_pycached_in_sitelib():
|
||||
|
Loading…
Reference in New Issue
Block a user