diff --git a/macros.python b/macros.python index 94e769c..8b168b5 100644 --- a/macros.python +++ b/macros.python @@ -1,51 +1,73 @@ %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}\ +# 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_install() %{expand:\ -CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py_build_egg() %{expand:\\\ + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 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\ +%py_build_wheel() %{expand:\\\ + CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} + sleep 1 +} + +%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 %{?*} +} + +%py_install_wheel() %{expand:\\\ + pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps +} + +%python_provide() %{lua: + function string.starts(String,Start) + return string.sub(String,1,string.len(Start))==Start + end + package = rpm.expand("%{?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..169d48f 100644 --- a/macros.python2 +++ b/macros.python2 @@ -6,11 +6,32 @@ %py2_shbang_opts -s -%py2_build() %{expand:\ -CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?1};\ -sleep 1\ +# 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_install() %{expand:\ -CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py2_build_egg() %{expand:\\\ + 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 +} + +%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 %{?*} +} + +%py2_install_wheel() %{expand:\\\ + pip%{python2_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps } diff --git a/macros.python3 b/macros.python3 index 4f44bd1..2805b8a 100644 --- a/macros.python3 +++ b/macros.python3 @@ -7,11 +7,32 @@ %py3_shbang_opts -s -%py3_build() %{expand:\ -CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?1};\ -sleep 1\ +# 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_install() %{expand:\ -CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +%py3_build_egg() %{expand:\\\ + 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 +} + +%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 %{?*} +} + +%py3_install_wheel() %{expand:\\\ + 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 3ad299c..fb8947e 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 @@ -50,25 +50,35 @@ RPM macros for building Python 3 packages. %build %install -mkdir -p %{buildroot}/%{_rpmconfigdir}/macros.d/ +mkdir -p %{buildroot}/%{rpmmacrodir} install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ - %{buildroot}/%{_rpmconfigdir}/macros.d/ + %{buildroot}/%{rpmmacrodir}/ %files -%{_rpmconfigdir}/macros.d/macros.python +%{rpmmacrodir}/macros.python %files -n python-srpm-macros -%{_rpmconfigdir}/macros.d/macros.python-srpm +%{rpmmacrodir}/macros.python-srpm %files -n python2-rpm-macros -%{_rpmconfigdir}/macros.d/macros.python2 +%{rpmmacrodir}/macros.python2 %files -n python3-rpm-macros -%{_rpmconfigdir}/macros.d/macros.python3 +%{rpmmacrodir}/macros.python3 %changelog +* Wed Feb 21 2017 Orion Poplawski 3-12 +- Make expanded macros start on the same line as the macro +- Add --no-deps option to py_install_wheel macros +- Add missing sleeps to other build macros +- Add %%py_build_wheel and %%py_install_wheel macros +- Add %%py_build_egg and %%py_install_egg macros +- Allow multiple args to %%py_build/install macros +- Tidy up macro formatting +- Use %%rpmmacrodir + * Tue Jan 17 2017 Tomas Orsava - 3-11 - Added macros for Build/Requires tags using Python dist tags: https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages