From 29e6636ccda30e3d6b64ab832e34648993a94e2d Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Tue, 15 Nov 2016 16:16:16 -0700 Subject: [PATCH 01/10] Tidy up macro formatting --- macros.python | 86 +++++++++++++++++++++++++------------------------- macros.python2 | 10 +++--- macros.python3 | 10 +++--- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/macros.python b/macros.python index 94e769c..12b626c 100644 --- a/macros.python +++ b/macros.python @@ -1,51 +1,51 @@ %py_setup setup.py %py_shbang_opts -s -%py_build() %{expand:\ -CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?1}\ +%py_build() %{expand: + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?1} } -%py_install() %{expand:\ -CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py_install() %{expand: + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} } -%python_provide() %{lua:\ - function string.starts(String,Start)\ - return string.sub(String,1,string.len(Start))==Start\ - end\ - package = rpm.expand("%{?1:%{1}}");\ - vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") - if (string.starts(package, "python2-")) then\ - if (rpm.expand("%{?buildarch}") ~= "noarch") then\ - str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr;\ - print(rpm.expand(str));\ - end\ - print("\\nProvides: python-");\ - print(string.sub(package,9,string.len(package)));\ - print(" = ");\ - print(vr);\ - --Obsoleting the previous default python package\ - print("\\nObsoletes: python-");\ - print(string.sub(package,9,string.len(package)));\ - print(" < ");\ - print(vr);\ - elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then\ - --No unversioned provides as python3 is not default\ - elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then\ - --No unversioned provides as python3_other is not default\ - elseif (string.starts(package, "pypy-")) then\ - --No unversioned provides as pypy is not default\ - elseif (string.starts(package, "pypy3-")) then\ - --No unversioned provides as pypy is not default\ - elseif (string.starts(package, "python-")) then\ - --Providing the current default python\ - print("Provides: python2-");\ - print(string.sub(package,8,string.len(package)));\ - print(" = ");\ - print(vr);\ - else\ - print("%python_provide: ERROR: ");\ - print(package);\ - print(" not recognized.");\ - end\ +%python_provide() %{lua: + function string.starts(String,Start) + return string.sub(String,1,string.len(Start))==Start + end + package = rpm.expand("%{?1:%{1}}") + vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") + if (string.starts(package, "python2-")) then + if (rpm.expand("%{?buildarch}") ~= "noarch") then + str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr + print(rpm.expand(str)) + end + print("\\nProvides: python-") + print(string.sub(package,9,string.len(package))) + print(" = ") + print(vr) + --Obsoleting the previous default python package + print("\\nObsoletes: python-") + print(string.sub(package,9,string.len(package))) + print(" < ") + print(vr) + elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then + --No unversioned provides as python3 is not default + elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then + --No unversioned provides as python3_other is not default + elseif (string.starts(package, "pypy-")) then + --No unversioned provides as pypy is not default + elseif (string.starts(package, "pypy3-")) then + --No unversioned provides as pypy is not default + elseif (string.starts(package, "python-")) then + --Providing the current default python + print("Provides: python2-") + print(string.sub(package,8,string.len(package))) + print(" = ") + print(vr) + else + print("%python_provide: ERROR: ") + print(package) + print(" not recognized.") + end } diff --git a/macros.python2 b/macros.python2 index 789ca09..b39a1b1 100644 --- a/macros.python2 +++ b/macros.python2 @@ -6,11 +6,11 @@ %py2_shbang_opts -s -%py2_build() %{expand:\ -CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?1};\ -sleep 1\ +%py2_build() %{expand: + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?1} + sleep 1 } -%py2_install() %{expand:\ -CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py2_install() %{expand: + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} } diff --git a/macros.python3 b/macros.python3 index 4f44bd1..f083b7a 100644 --- a/macros.python3 +++ b/macros.python3 @@ -7,11 +7,11 @@ %py3_shbang_opts -s -%py3_build() %{expand:\ -CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?1};\ -sleep 1\ +%py3_build() %{expand: + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?1} + sleep 1 } -%py3_install() %{expand:\ -CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py3_install() %{expand: + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} } From 6ce524f21d4b087f6cff6f98a0ee6e1eb404eff7 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Tue, 15 Nov 2016 16:18:39 -0700 Subject: [PATCH 02/10] Allow multiple args to %py_build/install macros --- macros.python | 6 +++--- macros.python2 | 4 ++-- macros.python3 | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/macros.python b/macros.python index 12b626c..2913a27 100644 --- a/macros.python +++ b/macros.python @@ -2,18 +2,18 @@ %py_shbang_opts -s %py_build() %{expand: - CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?1} + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?*} } %py_install() %{expand: - CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } %python_provide() %{lua: function string.starts(String,Start) return string.sub(String,1,string.len(Start))==Start end - package = rpm.expand("%{?1:%{1}}") + package = rpm.expand("%{?1}") vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") if (string.starts(package, "python2-")) then if (rpm.expand("%{?buildarch}") ~= "noarch") then diff --git a/macros.python2 b/macros.python2 index b39a1b1..a79b941 100644 --- a/macros.python2 +++ b/macros.python2 @@ -7,10 +7,10 @@ %py2_shbang_opts -s %py2_build() %{expand: - CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?1} + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?*} sleep 1 } %py2_install() %{expand: - CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } diff --git a/macros.python3 b/macros.python3 index f083b7a..665f9f2 100644 --- a/macros.python3 +++ b/macros.python3 @@ -8,10 +8,10 @@ %py3_shbang_opts -s %py3_build() %{expand: - CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?1} + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*} sleep 1 } %py3_install() %{expand: - CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1} + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } From f798c4335426a9c900a42ed28f34402416b0f4f8 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Tue, 15 Nov 2016 16:12:23 -0700 Subject: [PATCH 03/10] Add %py_build_egg and %py_install_egg macros --- macros.python | 9 +++++++++ macros.python2 | 10 ++++++++++ macros.python3 | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/macros.python b/macros.python index 2913a27..710678e 100644 --- a/macros.python +++ b/macros.python @@ -5,10 +5,19 @@ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?*} } +%py_build_egg() %{expand: + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python2} %{py_shbang_opts}" %{?*} +} + %py_install() %{expand: CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } +%py_install_egg() %{expand: + mkdir -p %{buildroot}%{python_sitelib} + easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*} +} + %python_provide() %{lua: function string.starts(String,Start) return string.sub(String,1,string.len(Start))==Start diff --git a/macros.python2 b/macros.python2 index a79b941..b5bc98a 100644 --- a/macros.python2 +++ b/macros.python2 @@ -11,6 +11,16 @@ sleep 1 } +%py2_build_egg() %{expand: + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python2} %{py2_shbang_opts}" %{?*} + sleep 1 +} + %py2_install() %{expand: CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } + +%py2_install_egg() %{expand: + mkdir -p %{buildroot}%{python2_sitelib} + easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*} +} diff --git a/macros.python3 b/macros.python3 index 665f9f2..fcf9964 100644 --- a/macros.python3 +++ b/macros.python3 @@ -12,6 +12,16 @@ sleep 1 } +%py3_build_egg() %{expand: + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python3} %{py3_shbang_opts}" %{?*} + sleep 1 +} + %py3_install() %{expand: CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } + +%py3_install_egg() %{expand: + mkdir -p %{buildroot}%{python3_sitelib} + easy_install-%{python3_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*} +} From bad56e0efe80f4e0d851bd83e77902a1f2f70a9f Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Tue, 15 Nov 2016 16:26:40 -0700 Subject: [PATCH 04/10] Bump release and add %changelog entry --- python-rpm-macros.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index f0804c1..a1cfffa 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 11%{?dist} +Release: 12%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,11 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Tue Nov 15 2016 Orion Poplawski 3-12 +- Add %%py_build_egg and %%py_install_egg macros +- Allow multiple args to %%py_build/install macros +- Tidy up macro formatting + * Wed Aug 24 2016 Orion Poplawski 3-11 - Use %%rpmmacrodir From e7af332922fbd543df3844d56313cd1f8b2d336c Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Wed, 16 Nov 2016 16:28:31 -0700 Subject: [PATCH 05/10] Add missing sleeps to other build macros - Fix build_egg macros - Add %py_build_wheel and %py_install_wheel macros --- macros.python | 13 ++++++++++++- macros.python2 | 11 ++++++++++- macros.python3 | 10 +++++++++- python-rpm-macros.spec | 7 ++++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/macros.python b/macros.python index 710678e..a0311ca 100644 --- a/macros.python +++ b/macros.python @@ -3,10 +3,17 @@ %py_build() %{expand: CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?*} + sleep 1 } %py_build_egg() %{expand: - CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python2} %{py_shbang_opts}" %{?*} + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 1 +} + +%py_build_wheel() %{expand: + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} + sleep 1 } %py_install() %{expand: @@ -18,6 +25,10 @@ easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*} } +%py_install_wheel() %{expand: + pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} +} + %python_provide() %{lua: function string.starts(String,Start) return string.sub(String,1,string.len(Start))==Start diff --git a/macros.python2 b/macros.python2 index b5bc98a..81e3aa5 100644 --- a/macros.python2 +++ b/macros.python2 @@ -12,7 +12,12 @@ } %py2_build_egg() %{expand: - CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python2} %{py2_shbang_opts}" %{?*} + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 1 +} + +%py2_build_wheel() %{expand: + CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} sleep 1 } @@ -24,3 +29,7 @@ mkdir -p %{buildroot}%{python2_sitelib} easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*} } + +%py2_install_wheel() %{expand: + pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} +} diff --git a/macros.python3 b/macros.python3 index fcf9964..984dbcd 100644 --- a/macros.python3 +++ b/macros.python3 @@ -13,7 +13,12 @@ } %py3_build_egg() %{expand: - CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_egg --executable="%{__python3} %{py3_shbang_opts}" %{?*} + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 1 +} + +%py3_build_wheel() %{expand: + CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} sleep 1 } @@ -25,3 +30,6 @@ mkdir -p %{buildroot}%{python3_sitelib} easy_install-%{python3_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*} } + +%py3_install_wheel() %{expand: + pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index a1cfffa..62c7977 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 12%{?dist} +Release: 13%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,11 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Wed Nov 16 2016 Orion Poplawski 3-13 +- Add missing sleeps to other build macros +- Fix build_egg macros +- Add %%py_build_wheel and %%py_install_wheel macros + * Tue Nov 15 2016 Orion Poplawski 3-12 - Add %%py_build_egg and %%py_install_egg macros - Allow multiple args to %%py_build/install macros From a73eb24716ec8777f857f2419de2bfcf05eb40e3 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Wed, 16 Nov 2016 21:32:46 -0700 Subject: [PATCH 06/10] Fix %py3_install_wheel (bug #1395953) --- macros.python3 | 1 + python-rpm-macros.spec | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/macros.python3 b/macros.python3 index 984dbcd..2cabc40 100644 --- a/macros.python3 +++ b/macros.python3 @@ -33,3 +33,4 @@ %py3_install_wheel() %{expand: pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} +} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 62c7977..ed94d9d 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 13%{?dist} +Release: 14%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Wed Nov 16 2016 Orion Poplawski 3-14 +- Fix %%py3_install_wheel (bug #1395953) + * Wed Nov 16 2016 Orion Poplawski 3-13 - Add missing sleeps to other build macros - Fix build_egg macros From 5ca1f525e5551e4c80d4168e5eebd56c95eda531 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 24 Nov 2016 07:53:47 -0700 Subject: [PATCH 07/10] Make expaned macros start on the same line as the macro --- macros.python | 14 ++++++++------ macros.python2 | 14 ++++++++------ macros.python3 | 14 ++++++++------ python-rpm-macros.spec | 5 ++++- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/macros.python b/macros.python index a0311ca..aab13c0 100644 --- a/macros.python +++ b/macros.python @@ -1,31 +1,33 @@ %py_setup setup.py %py_shbang_opts -s -%py_build() %{expand: +# Use the slashes after expand so that the command starts on the same line as +# the macro +%py_build() %{expand:\\\ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?*} sleep 1 } -%py_build_egg() %{expand: +%py_build_egg() %{expand:\\\ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*} sleep 1 } -%py_build_wheel() %{expand: +%py_build_wheel() %{expand:\\\ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} sleep 1 } -%py_install() %{expand: +%py_install() %{expand:\\\ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } -%py_install_egg() %{expand: +%py_install_egg() %{expand:\\\ mkdir -p %{buildroot}%{python_sitelib} easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*} } -%py_install_wheel() %{expand: +%py_install_wheel() %{expand:\\\ pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} } diff --git a/macros.python2 b/macros.python2 index 81e3aa5..420544b 100644 --- a/macros.python2 +++ b/macros.python2 @@ -6,30 +6,32 @@ %py2_shbang_opts -s -%py2_build() %{expand: +# Use the slashes after expand so that the command starts on the same line as +# the macro +%py2_build() %{expand:\\\ CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?*} sleep 1 } -%py2_build_egg() %{expand: +%py2_build_egg() %{expand:\\\ CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_egg %{?*} sleep 1 } -%py2_build_wheel() %{expand: +%py2_build_wheel() %{expand:\\\ CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} sleep 1 } -%py2_install() %{expand: +%py2_install() %{expand:\\\ CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } -%py2_install_egg() %{expand: +%py2_install_egg() %{expand:\\\ mkdir -p %{buildroot}%{python2_sitelib} easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*} } -%py2_install_wheel() %{expand: +%py2_install_wheel() %{expand:\\\ pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} } diff --git a/macros.python3 b/macros.python3 index 2cabc40..c81cf3f 100644 --- a/macros.python3 +++ b/macros.python3 @@ -7,30 +7,32 @@ %py3_shbang_opts -s -%py3_build() %{expand: +# Use the slashes after expand so that the command starts on the same line as +# the macro +%py3_build() %{expand:\\\ CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*} sleep 1 } -%py3_build_egg() %{expand: +%py3_build_egg() %{expand:\\\ CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*} sleep 1 } -%py3_build_wheel() %{expand: +%py3_build_wheel() %{expand:\\\ CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} sleep 1 } -%py3_install() %{expand: +%py3_install() %{expand:\\\ CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} } -%py3_install_egg() %{expand: +%py3_install_egg() %{expand:\\\ mkdir -p %{buildroot}%{python3_sitelib} easy_install-%{python3_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*} } -%py3_install_wheel() %{expand: +%py3_install_wheel() %{expand:\\\ pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} } diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index ed94d9d..055a3f0 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 14%{?dist} +Release: 15%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Thu Nov 24 2016 Orion Poplawski 3-15 +- Make expaned macros start on the same line as the macro + * Wed Nov 16 2016 Orion Poplawski 3-14 - Fix %%py3_install_wheel (bug #1395953) From 516c55eed718753e8484a1c45bb87eb8236e8282 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 24 Nov 2016 07:59:27 -0700 Subject: [PATCH 08/10] Fix typo in changelog --- python-rpm-macros.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 055a3f0..1ab3223 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -70,7 +70,7 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog * Thu Nov 24 2016 Orion Poplawski 3-15 -- Make expaned macros start on the same line as the macro +- Make expanded macros start on the same line as the macro * Wed Nov 16 2016 Orion Poplawski 3-14 - Fix %%py3_install_wheel (bug #1395953) From 123ad4b49f392a6fb61c8a23caab44fc8ae163b5 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Tue, 17 Jan 2017 10:28:13 +0100 Subject: [PATCH 09/10] Added macros for Build/Requires tags using Python dist tags https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages --- macros.python-srpm | 55 ++++++++++++++++++++++++++++++++++++++++++ python-rpm-macros.spec | 6 ++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/macros.python-srpm b/macros.python-srpm index 87ce887..38a71dc 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -6,3 +6,58 @@ %__python3_other /bin/true %py3_other_build /bin/true %py3_other_install /bin/true + + + +# === Macros for Build/Requires tags using Python dist tags === +# - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages +# - These macros need to be in macros.python-srpm, because BuildRequires tags +# get rendered as runtime requires into the metadata of SRPMs. + +# Converts Python dist name to a canonical format +%py_dist_name() %{lua:\ + name = rpm.expand("%{?1:%{1}}");\ + canonical = string.gsub(string.lower(name), "%W+", "-");\ + print(canonical);\ +} + +# Creates Python 2 dist tag(s) after converting names to canonical format +# Needs to first put all arguments into a list, because invoking a different +# macro (%py_dist_name) overwrites them +%py2_dist() %{lua:\ + args = {}\ + arg = 1\ + while (true) do\ + name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\ + if (name == nil or name == '') then\ + break\ + end\ + args[arg] = name\ + arg = arg + 1\ + end\ + for arg, name in ipairs(args) do\ + canonical = rpm.expand("%py_dist_name " .. name);\ + print("python2dist(" .. canonical .. ") ");\ + end\ +} + +# Creates Python 3 dist tag(s) after converting names to canonical format +# Needs to first put all arguments into a list, because invoking a different +# macro (%py_dist_name) overwrites them +%py3_dist() %{lua:\ + args = {}\ + arg = 1\ + while (true) do\ + name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\ + if (name == nil or name == '') then\ + break\ + end\ + args[arg] = name\ + arg = arg + 1\ + end\ + for arg, name in ipairs(args) do\ + canonical = rpm.expand("%py_dist_name " .. name);\ + print("python3dist(" .. canonical .. ") ");\ + end\ +} + diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 1ab3223..32d1604 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 15%{?dist} +Release: 16%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,10 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Tue Jan 17 2017 Tomas Orsava - 3-16 +- Added macros for Build/Requires tags using Python dist tags: + https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + * Thu Nov 24 2016 Orion Poplawski 3-15 - Make expanded macros start on the same line as the macro From d0fdb0d759b960b41b57bf7c9539901f16062e0a Mon Sep 17 00:00:00 2001 From: Michal Cyprian Date: Mon, 23 Jan 2017 18:52:17 +0100 Subject: [PATCH 10/10] Add --no-deps option to py_install_wheel macros --- macros.python | 2 +- macros.python2 | 2 +- macros.python3 | 2 +- python-rpm-macros.spec | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/macros.python b/macros.python index aab13c0..8b168b5 100644 --- a/macros.python +++ b/macros.python @@ -28,7 +28,7 @@ } %py_install_wheel() %{expand:\\\ - pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} + pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps } %python_provide() %{lua: diff --git a/macros.python2 b/macros.python2 index 420544b..169d48f 100644 --- a/macros.python2 +++ b/macros.python2 @@ -33,5 +33,5 @@ } %py2_install_wheel() %{expand:\\\ - pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} + pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps } diff --git a/macros.python3 b/macros.python3 index c81cf3f..2805b8a 100644 --- a/macros.python3 +++ b/macros.python3 @@ -34,5 +34,5 @@ } %py3_install_wheel() %{expand:\\\ - pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} + pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps } diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 32d1604..be402c9 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 16%{?dist} +Release: 17%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -69,6 +69,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Mon Jan 23 2017 Michal Cyprian - 3-17 +- Add --no-deps option to py_install_wheel macros + * Tue Jan 17 2017 Tomas Orsava - 3-16 - Added macros for Build/Requires tags using Python dist tags: https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages