From 86a7ec8de5a6de252986e63c8268cb394cb493f5 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 14 Jan 2016 14:32:55 -0700 Subject: [PATCH 01/15] EPEL version --- macros.python-srpm | 7 ++++++- python-rpm-macros.spec | 11 ++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index 4257beb..b515582 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -1,3 +1,8 @@ # python3_pkgversion specifies the version of Python 3 in the distro. It can be # a specific version (e.g. 34 in Fedora EPEL7) -%python3_pkgversion 3 +%python3_pkgversion 34 +#python3_other_pkgversion 35 +# Set to /bin/true when not active to avoid %ifdefs in specfiles +%__python3_other /bin/true +%py3_other_build /bin/true +%py3_other_install /bin/true diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index d71e19c..52a97a2 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 4%{?dist} +Release: 4%{?dist}.1 Summary: The unversioned Python RPM macros License: MIT @@ -10,8 +10,6 @@ Source2: macros.python2 Source3: macros.python3 BuildArch: noarch -Obsoletes: python-macros < 3 -Provides: python-macros = %{version}-%{release} %description This package contains the unversioned Python RPM macros, that most @@ -28,16 +26,12 @@ RPM macros for building Python source packages. %package -n python2-rpm-macros Summary: RPM macros for building Python 2 packages -# Would need to be different for each release - worth it? -#Conflicts: python2-devel < 2.7.11-3 %description -n python2-rpm-macros RPM macros for building Python 2 packages. %package -n python3-rpm-macros Summary: RPM macros for building Python 3 packages -# Would need to be different for each release - worth it? -#Conflicts: python3-devel < 3.5.1-3 %description -n python3-rpm-macros RPM macros for building Python 3 packages. @@ -67,6 +61,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Thu Jan 14 2016 Orion Poplawski 3-4.1 +- EPEL version + * Wed Jan 13 2016 Orion Poplawski 3-4 - Fix python2/3-rpm-macros package names From 237061d265a11c86275ecae37d4c0117820ed79c Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Thu, 14 Jan 2016 14:46:42 -0700 Subject: [PATCH 02/15] Handle python3_other_pkgversion in python_provide; Drop duplicate py3_other macros from macros.python --- macros.python | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/macros.python b/macros.python index 4a5cb2a..a4c2fc8 100644 --- a/macros.python +++ b/macros.python @@ -29,8 +29,10 @@ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --ski print(string.sub(package,9,string.len(package)));\ print(" < ");\ print(vr);\ - elseif (string.starts(package, "python3-")) then\ + elseif (string.starts(str, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then\ --No unversioned provides as python3 is not default\ + elseif (rpm.expand("%{?python3_other_pkgversion}") != "" and string.starts(str, "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\ @@ -47,8 +49,3 @@ CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --ski print("not recognized.");\ end\ } - -# Set to /bin/true to avoid %ifdefs in specfiles -%__python3_other /bin/true -%py3_other_build /bin/true -%py3_other_install /bin/true From cc0b15603c86a16c2727a7a19bf8b93442ac046d Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 25 Jan 2016 16:55:23 -0700 Subject: [PATCH 03/15] Set %__python3 to /usr/bin/python3.4 --- macros.python3 | 4 +++- python-rpm-macros.spec | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/macros.python3 b/macros.python3 index a633c72..7f00724 100644 --- a/macros.python3 +++ b/macros.python3 @@ -1,4 +1,6 @@ -%__python3 /usr/bin/python3 +%__python3 /usr/bin/python3.4 +#__python3_other /usr/bin/python3.5 + %python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])") diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index b703fcb..b720e8d 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 6%{?dist} +Release: 6%{?dist}.1 Summary: The unversioned Python RPM macros License: MIT @@ -61,6 +61,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Mon Jan 25 2016 Orion Poplawski 3-6.1 +- Set %%__python3 to /usr/bin/python3.4 + * Thu Jan 14 2016 Orion Poplawski 3-6 - Fix typo in %%python_provide From 6c29671c63275ece01c2be9e78467bdf283d458c Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Wed, 20 Dec 2017 23:06:54 +0100 Subject: [PATCH 04/15] Add python36 as EPEL's other python --- macros.python-srpm | 2 +- macros.python3 | 2 +- python-rpm-macros.spec | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index 03d26a3..6ca124f 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -1,7 +1,7 @@ # python3_pkgversion specifies the version of Python 3 in the distro. It can be # a specific version (e.g. 34 in Fedora EPEL7) %python3_pkgversion 34 -#python3_other_pkgversion 35 +%python3_other_pkgversion 36 # Set to /bin/true when not active to avoid %ifdefs and %{? in specfiles %__python3_other /bin/true diff --git a/macros.python3 b/macros.python3 index b7ebe72..d313235 100644 --- a/macros.python3 +++ b/macros.python3 @@ -1,5 +1,5 @@ %__python3 /usr/bin/python3.4 -#__python3_other /usr/bin/python3.5 +%__python3_other /usr/bin/python3.6 %python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index dda6edf..6f3e30e 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 17%{?dist} +Release: 18%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -63,6 +63,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Wed Dec 20 2017 Charalampos Stratakis - 3-18 +- Add python36 in EPEL 7. + * Mon Jan 23 2017 Michal Cyprian - 3-17 - Add --no-deps option to py_install_wheel macros From 06d80134eb2504da24ab5df7d0d02d02d35ee354 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Mon, 18 Jun 2018 18:12:26 -0500 Subject: [PATCH 05/15] Add %pypi_source macro. --- macros.python-srpm | 44 ++++++++++++++++++++++++++++++++++++++++++ python-rpm-macros.spec | 5 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/macros.python-srpm b/macros.python-srpm index 6ca124f..14774b9 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -62,3 +62,47 @@ end\ } +# Macro to replace overly complicated references to PyPI source files. +# Expands to the pythonhosted URL for a package +# Accepts zero to three arguments: +# 1: The PyPI project name, defaulting to %srcname if it is defined, then +# %pypi_name if it is defined, then just %name. +# 2: The PYPI version, defaulting to %version. +# 3: The file extension, defaulting to "tar.gz". (A period will be added +# automatically.) +# Requires %__pypi_url and %__pypi_default_extension to be defined. +%__pypi_url https://files.pythonhosted.org/packages/source/ +%__pypi_default_extension tar.gz + +%pypi_source() %{lua: + local src = rpm.expand('%1') + local ver = rpm.expand('%2') + local ext = rpm.expand('%3') + local url = rpm.expand('%__pypi_url') +\ + -- If no first argument, try %srcname, then %pypi_name, then %name + -- Note that rpm leaves macros unchanged if they are not defined. + if src == '%1' then + src = rpm.expand('%srcname') + end + if src == '%srcname' then + src = rpm.expand('%pypi_name') + end + if src == '%pypi_name' then + src = rpm.expand('%name') + end +\ + -- If no second argument, use %version + if ver == '%2' then + ver = rpm.expand('%version') + end +\ + -- If no third argument, use the preset default extension + if ext == '%3' then + ext = rpm.expand('%__pypi_default_extension') + end +\ + local first = string.sub(src, 1, 1) +\ + print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext) +} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 6f3e30e..6d8aea2 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 18%{?dist} +Release: 19%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -63,6 +63,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %changelog +* Mon Jun 18 2018 Jason L Tibbitts III - 3-19 +- Add %%pypi_source macro. + * Wed Dec 20 2017 Charalampos Stratakis - 3-18 - Add python36 in EPEL 7. From 8ef228123aaa5150878bfdbe10f06237c71a74ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Jane=C5=BE?= Date: Mon, 11 Jun 2018 10:50:22 +0200 Subject: [PATCH 06/15] Add %python3_other_* counterparts for %python3_* macros in EPEL 7 --- macros.python3 | 1 - macros.python3_other | 38 ++++++++++++++++++++++++++++++++++++++ python-rpm-macros.spec | 9 +++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 macros.python3_other diff --git a/macros.python3 b/macros.python3 index d313235..2313da2 100644 --- a/macros.python3 +++ b/macros.python3 @@ -1,5 +1,4 @@ %__python3 /usr/bin/python3.4 -%__python3_other /usr/bin/python3.6 %python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") diff --git a/macros.python3_other b/macros.python3_other new file mode 100644 index 0000000..a15dca5 --- /dev/null +++ b/macros.python3_other @@ -0,0 +1,38 @@ +%__python3_other /usr/bin/python3.6 + +%python3_other_sitelib %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") +%python3_other_sitearch %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") +%python3_other_version %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3])") +%python3_other_version_nodots %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") + +%py3_other_shbang_opts -s + +# Use the slashes after expand so that the command starts on the same line as +# the macro +%py3_other_build() %{expand:\\\ + CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} build --executable="%{__python3_other} %{py3_other_shbang_opts}" %{?*} + sleep 1 +} + +%py3_other_build_egg() %{expand:\\\ + CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 1 +} + +%py3_other_build_wheel() %{expand:\\\ + CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} + sleep 1 +} + +%py3_other_install() %{expand:\\\ + CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} +} + +%py3_other_install_egg() %{expand:\\\ + mkdir -p %{buildroot}%{python3_other_sitelib} + easy_install-%{python3_other_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_other_version}.egg %{?*} +} + +%py3_other_install_wheel() %{expand:\\\ + pip%{python3_other_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 6d8aea2..7ee0f1e 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 19%{?dist} +Release: 20%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -8,6 +8,7 @@ Source0: macros.python Source1: macros.python-srpm Source2: macros.python2 Source3: macros.python3 +Source4: macros.python3_other BuildArch: noarch # For %%python3_pkgversion used in %%python_provide @@ -45,7 +46,7 @@ RPM macros for building Python 3 packages. %install mkdir -p %{buildroot}/%{rpmmacrodir} -install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %{buildroot}/%{rpmmacrodir}/ @@ -60,9 +61,13 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ %files -n python3-rpm-macros %{rpmmacrodir}/macros.python3 +%{rpmmacrodir}/macros.python3_other %changelog +* Thu Jun 21 2018 Tadej Janež - 3-20 +- Add %%python3_other_* counterparts for %%python3_* macros in EPEL 7 + * Mon Jun 18 2018 Jason L Tibbitts III - 3-19 - Add %%pypi_source macro. From ef7f75882aad4f71bf7f5c590ebac19f19f1103f Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Mon, 9 Jul 2018 14:44:54 -0500 Subject: [PATCH 07/15] Add %python3(_other)?_platform macros. --- macros.python3 | 1 + macros.python3_other | 1 + python-rpm-macros.spec | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/macros.python3 b/macros.python3 index 2313da2..a188a7f 100644 --- a/macros.python3 +++ b/macros.python3 @@ -4,6 +4,7 @@ %python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])") %python3_version_nodots %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") +%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") %py3dir %{_builddir}/python3-%{name}-%{version}-%{release} %py3_shbang_opts -s diff --git a/macros.python3_other b/macros.python3_other index a15dca5..320b151 100644 --- a/macros.python3_other +++ b/macros.python3_other @@ -4,6 +4,7 @@ %python3_other_sitearch %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %python3_other_version %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3])") %python3_other_version_nodots %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") +%python3_other_platform %(%{__python3_other} -Ic "import sysconfig; print(sysconfig.get_platform())") %py3_other_shbang_opts -s diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 7ee0f1e..72ac71e 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 20%{?dist} +Release: 21%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -65,6 +65,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %changelog +* Mon Jul 09 2018 Jason L Tibbitts III - 3-21 +- Backport %%python3_platform and add %%python3_other_platform. + * Thu Jun 21 2018 Tadej Janež - 3-20 - Add %%python3_other_* counterparts for %%python3_* macros in EPEL 7 From 0fe7b8e184cfa9667ea0df4e5ab5d6f4944a4af5 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Wed, 11 Jul 2018 15:11:52 +0200 Subject: [PATCH 08/15] Move macros.pybytecompile in here from python3X-devel macros.pybytecompile: Detect Python version through sys.version_info ...instead of guessing from the executable name. This should make it work on EPEL7 as well where we ship 3.4 and 3.6 https://bugzilla.redhat.com/show_bug.cgi?id=1599809 --- macros.pybytecompile | 27 +++++++++++++++++++++++++++ python-rpm-macros.spec | 11 +++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 macros.pybytecompile diff --git a/macros.pybytecompile b/macros.pybytecompile new file mode 100644 index 0000000..f5439cf --- /dev/null +++ b/macros.pybytecompile @@ -0,0 +1,27 @@ +# Note that the path could itself be a python file, or a directory + +# Python's compile_all module only works on directories, and requires a max +# recursion depth + +# Note that the py_byte_compile macro should work for all Python versions +# Which unfortunately makes the definition more complicated than it should be + +%py_byte_compile()\ +py2_byte_compile () {\ + python_binary="%1"\ + bytecode_compilation_path="%2"\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ +}\ +\ +py3_byte_compile () {\ + python_binary="%1"\ + bytecode_compilation_path="%2"\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2], optimize=opt) for opt in range(2) for f in sys.argv[1:]]' || :\ +}\ +\ +# Get version without a dot (36 instead of 3.6), bash doesn't compare floats well \ +python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \ +# The bytecompilation syntax has changed between Python 3.4 and Python 3.5, so for 3.4 and earlier we use the "Python 2" syntax \ +[ "$python_version" -ge 35 ] && py3_byte_compile "%1" "%2" || py2_byte_compile "%1" "%2" \ +%{nil} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 72ac71e..36b5a6a 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 21%{?dist} +Release: 22%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -9,6 +9,7 @@ Source1: macros.python-srpm Source2: macros.python2 Source3: macros.python3 Source4: macros.python3_other +Source5: macros.pybytecompile BuildArch: noarch # For %%python3_pkgversion used in %%python_provide @@ -46,12 +47,13 @@ RPM macros for building Python 3 packages. %install mkdir -p %{buildroot}/%{rpmmacrodir} -install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} \ %{buildroot}/%{rpmmacrodir}/ %files %{rpmmacrodir}/macros.python +%{rpmmacrodir}/macros.pybytecompile %files -n python-srpm-macros %{rpmmacrodir}/macros.python-srpm @@ -65,6 +67,11 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %changelog +* Sat Jul 14 2018 Tomas Orsava - 3-22 +- Move macros.pybytecompile in here from python3X-devel +- macros.pybytecompile: Detect Python version through sys.version_info instead + of guessing from the executable name + * Mon Jul 09 2018 Jason L Tibbitts III - 3-21 - Backport %%python3_platform and add %%python3_other_platform. From 99f8b82d04ce08c351bdde3a758de46e9f18a86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 4 Feb 2019 15:05:57 +0100 Subject: [PATCH 09/15] Switch 3.4 and 3.6 --- macros.python-srpm | 6 +++--- macros.python3 | 2 +- macros.python3_other | 2 +- python-rpm-macros.spec | 6 +++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index 14774b9..92193f8 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -1,7 +1,7 @@ # python3_pkgversion specifies the version of Python 3 in the distro. It can be -# a specific version (e.g. 34 in Fedora EPEL7) -%python3_pkgversion 34 -%python3_other_pkgversion 36 +# a specific version (e.g. 36 in Fedora EPEL7) +%python3_pkgversion 36 +%python3_other_pkgversion 34 # Set to /bin/true when not active to avoid %ifdefs and %{? in specfiles %__python3_other /bin/true diff --git a/macros.python3 b/macros.python3 index a188a7f..242e72a 100644 --- a/macros.python3 +++ b/macros.python3 @@ -1,4 +1,4 @@ -%__python3 /usr/bin/python3.4 +%__python3 /usr/bin/python3.6 %python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") diff --git a/macros.python3_other b/macros.python3_other index 320b151..1ce91ec 100644 --- a/macros.python3_other +++ b/macros.python3_other @@ -1,4 +1,4 @@ -%__python3_other /usr/bin/python3.6 +%__python3_other /usr/bin/python3.4 %python3_other_sitelib %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") %python3_other_sitearch %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 36b5a6a..fc73d05 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 22%{?dist} +Release: 23%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -67,6 +67,10 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %changelog +* Thu Jan 31 2019 Miro Hrončok - 3-23 +- Make Python 3.6 the main Python 3 version +- Make Python 3.4 the other Python 3 version + * Sat Jul 14 2018 Tomas Orsava - 3-22 - Move macros.pybytecompile in here from python3X-devel - macros.pybytecompile: Detect Python version through sys.version_info instead From efb740f8202b37dab001dcb4481529aa51194bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 25 Apr 2019 16:39:04 +0200 Subject: [PATCH 10/15] %python_provide: Obsolete and provide py36- from py3-, provide py3- from py36- The "python36" is intentionally hardcoded and does not use the %python3_pkgversion macro, as that can be overridden in spec for various reasons. See https://lists.fedoraproject.org/archives/list/epel-devel@lists.fedoraproject.org/message/RYDGY4BKYTLYH5IOECMPEZYFUZEXCDRN/ --- macros.python | 25 +++++++++++++++++++++++-- python-rpm-macros.spec | 6 +++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/macros.python b/macros.python index 8b168b5..37961b0 100644 --- a/macros.python +++ b/macros.python @@ -51,8 +51,29 @@ 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 (string.starts(package, "python3-")) then + if (rpm.expand("%{?buildarch}") ~= "noarch") then + str = "Provides: python36-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr + print(rpm.expand(str)) + end + print("\\nProvides: python36-") + print(string.sub(package,9,string.len(package))) + print(" = ") + print(vr) + --Obsoleting the EPEL python36 package + print("\\nObsoletes: python36-") + print(string.sub(package,9,string.len(package))) + print(" < ") + print(vr) + elseif (string.starts(package, "python36-")) then + if (rpm.expand("%{?buildarch}") ~= "noarch") then + str = "Provides: python3-" .. string.sub(package,10,string.len(package)) .. "%{?_isa} = " .. vr + print(rpm.expand(str)) + end + print("\\nProvides: python3-") + print(string.sub(package,10,string.len(package))) + print(" = ") + print(vr) 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 diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index fc73d05..979e1eb 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 23%{?dist} +Release: 24%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -67,6 +67,10 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %changelog +* Thu Apr 25 2019 Miro Hrončok - 3-24 +- %%python_provide: Obsolete and provide python36- from python3- +- %%python_provide: Provide python3- from python36- + * Thu Jan 31 2019 Miro Hrončok - 3-23 - Make Python 3.6 the main Python 3 version - Make Python 3.4 the other Python 3 version From 255d30c7f4d7cfb8e2bb286601ca1f2ab624b1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 30 Apr 2019 11:25:57 +0200 Subject: [PATCH 11/15] Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros --- macros.python3_other | 39 --------------------------------------- python-rpm-macros.spec | 9 +++++---- 2 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 macros.python3_other diff --git a/macros.python3_other b/macros.python3_other deleted file mode 100644 index 1ce91ec..0000000 --- a/macros.python3_other +++ /dev/null @@ -1,39 +0,0 @@ -%__python3_other /usr/bin/python3.4 - -%python3_other_sitelib %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -%python3_other_sitearch %(%{__python3_other} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%python3_other_version %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3])") -%python3_other_version_nodots %(%{__python3_other} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") -%python3_other_platform %(%{__python3_other} -Ic "import sysconfig; print(sysconfig.get_platform())") - -%py3_other_shbang_opts -s - -# Use the slashes after expand so that the command starts on the same line as -# the macro -%py3_other_build() %{expand:\\\ - CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} build --executable="%{__python3_other} %{py3_other_shbang_opts}" %{?*} - sleep 1 -} - -%py3_other_build_egg() %{expand:\\\ - CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} bdist_egg %{?*} - sleep 1 -} - -%py3_other_build_wheel() %{expand:\\\ - CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} - sleep 1 -} - -%py3_other_install() %{expand:\\\ - CFLAGS="%{optflags}" %{__python3_other} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*} -} - -%py3_other_install_egg() %{expand:\\\ - mkdir -p %{buildroot}%{python3_other_sitelib} - easy_install-%{python3_other_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_other_version}.egg %{?*} -} - -%py3_other_install_wheel() %{expand:\\\ - pip%{python3_other_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 979e1eb..5274291 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 24%{?dist} +Release: 25%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -8,7 +8,6 @@ Source0: macros.python Source1: macros.python-srpm Source2: macros.python2 Source3: macros.python3 -Source4: macros.python3_other Source5: macros.pybytecompile BuildArch: noarch @@ -47,7 +46,7 @@ RPM macros for building Python 3 packages. %install mkdir -p %{buildroot}/%{rpmmacrodir} -install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} \ +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} \ %{buildroot}/%{rpmmacrodir}/ @@ -63,10 +62,12 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %files -n python3-rpm-macros %{rpmmacrodir}/macros.python3 -%{rpmmacrodir}/macros.python3_other %changelog +* Tue Apr 30 2019 Miro Hrončok - 3-25 +- Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros + * Thu Apr 25 2019 Miro Hrončok - 3-24 - %%python_provide: Obsolete and provide python36- from python3- - %%python_provide: Provide python3- from python36- From b6f2fa0c7616565c964e5c72ecfddb6e712c2266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 9 Aug 2019 15:40:26 +0200 Subject: [PATCH 12/15] Included in RHEL 7.7+ --- .gitignore | 0 dead.package | 1 + macros.pybytecompile | 27 ------- macros.python | 94 ------------------------- macros.python-srpm | 108 ---------------------------- macros.python2 | 37 ---------- macros.python3 | 40 ----------- python-rpm-macros.spec | 156 ----------------------------------------- sources | 0 9 files changed, 1 insertion(+), 462 deletions(-) delete mode 100644 .gitignore create mode 100644 dead.package delete mode 100644 macros.pybytecompile delete mode 100644 macros.python delete mode 100644 macros.python-srpm delete mode 100644 macros.python2 delete mode 100644 macros.python3 delete mode 100644 python-rpm-macros.spec delete mode 100644 sources diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/dead.package b/dead.package new file mode 100644 index 0000000..7d96bd7 --- /dev/null +++ b/dead.package @@ -0,0 +1 @@ +Included in RHEL 7.7+ diff --git a/macros.pybytecompile b/macros.pybytecompile deleted file mode 100644 index f5439cf..0000000 --- a/macros.pybytecompile +++ /dev/null @@ -1,27 +0,0 @@ -# Note that the path could itself be a python file, or a directory - -# Python's compile_all module only works on directories, and requires a max -# recursion depth - -# Note that the py_byte_compile macro should work for all Python versions -# Which unfortunately makes the definition more complicated than it should be - -%py_byte_compile()\ -py2_byte_compile () {\ - python_binary="%1"\ - bytecode_compilation_path="%2"\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ -}\ -\ -py3_byte_compile () {\ - python_binary="%1"\ - bytecode_compilation_path="%2"\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2], optimize=opt) for opt in range(2) for f in sys.argv[1:]]' || :\ -}\ -\ -# Get version without a dot (36 instead of 3.6), bash doesn't compare floats well \ -python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \ -# The bytecompilation syntax has changed between Python 3.4 and Python 3.5, so for 3.4 and earlier we use the "Python 2" syntax \ -[ "$python_version" -ge 35 ] && py3_byte_compile "%1" "%2" || py2_byte_compile "%1" "%2" \ -%{nil} diff --git a/macros.python b/macros.python deleted file mode 100644 index 37961b0..0000000 --- a/macros.python +++ /dev/null @@ -1,94 +0,0 @@ -%py_setup setup.py -%py_shbang_opts -s - -# 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:\\\ - 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:\\\ - 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, "python3-")) then - if (rpm.expand("%{?buildarch}") ~= "noarch") then - str = "Provides: python36-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr - print(rpm.expand(str)) - end - print("\\nProvides: python36-") - print(string.sub(package,9,string.len(package))) - print(" = ") - print(vr) - --Obsoleting the EPEL python36 package - print("\\nObsoletes: python36-") - print(string.sub(package,9,string.len(package))) - print(" < ") - print(vr) - elseif (string.starts(package, "python36-")) then - if (rpm.expand("%{?buildarch}") ~= "noarch") then - str = "Provides: python3-" .. string.sub(package,10,string.len(package)) .. "%{?_isa} = " .. vr - print(rpm.expand(str)) - end - print("\\nProvides: python3-") - print(string.sub(package,10,string.len(package))) - print(" = ") - print(vr) - 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.python-srpm b/macros.python-srpm deleted file mode 100644 index 92193f8..0000000 --- a/macros.python-srpm +++ /dev/null @@ -1,108 +0,0 @@ -# python3_pkgversion specifies the version of Python 3 in the distro. It can be -# a specific version (e.g. 36 in Fedora EPEL7) -%python3_pkgversion 36 -%python3_other_pkgversion 34 - -# Set to /bin/true when not active to avoid %ifdefs and %{? in specfiles -%__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\ -} - -# Macro to replace overly complicated references to PyPI source files. -# Expands to the pythonhosted URL for a package -# Accepts zero to three arguments: -# 1: The PyPI project name, defaulting to %srcname if it is defined, then -# %pypi_name if it is defined, then just %name. -# 2: The PYPI version, defaulting to %version. -# 3: The file extension, defaulting to "tar.gz". (A period will be added -# automatically.) -# Requires %__pypi_url and %__pypi_default_extension to be defined. -%__pypi_url https://files.pythonhosted.org/packages/source/ -%__pypi_default_extension tar.gz - -%pypi_source() %{lua: - local src = rpm.expand('%1') - local ver = rpm.expand('%2') - local ext = rpm.expand('%3') - local url = rpm.expand('%__pypi_url') -\ - -- If no first argument, try %srcname, then %pypi_name, then %name - -- Note that rpm leaves macros unchanged if they are not defined. - if src == '%1' then - src = rpm.expand('%srcname') - end - if src == '%srcname' then - src = rpm.expand('%pypi_name') - end - if src == '%pypi_name' then - src = rpm.expand('%name') - end -\ - -- If no second argument, use %version - if ver == '%2' then - ver = rpm.expand('%version') - end -\ - -- If no third argument, use the preset default extension - if ext == '%3' then - ext = rpm.expand('%__pypi_default_extension') - end -\ - local first = string.sub(src, 1, 1) -\ - print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext) -} diff --git a/macros.python2 b/macros.python2 deleted file mode 100644 index 169d48f..0000000 --- a/macros.python2 +++ /dev/null @@ -1,37 +0,0 @@ -%__python2 /usr/bin/python2 -%python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -%python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%python2_version %(%{__python2} -c "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") -%python2_version_nodots %(%{__python2} -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") - -%py2_shbang_opts -s - -# 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:\\\ - 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 deleted file mode 100644 index 242e72a..0000000 --- a/macros.python3 +++ /dev/null @@ -1,40 +0,0 @@ -%__python3 /usr/bin/python3.6 - -%python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -%python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])") -%python3_version_nodots %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") -%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") -%py3dir %{_builddir}/python3-%{name}-%{version}-%{release} - -%py3_shbang_opts -s - -# 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:\\\ - 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 deleted file mode 100644 index 5274291..0000000 --- a/python-rpm-macros.spec +++ /dev/null @@ -1,156 +0,0 @@ -Name: python-rpm-macros -Version: 3 -Release: 25%{?dist} -Summary: The unversioned Python RPM macros - -License: MIT -Source0: macros.python -Source1: macros.python-srpm -Source2: macros.python2 -Source3: macros.python3 -Source5: macros.pybytecompile - -BuildArch: noarch -# For %%python3_pkgversion used in %%python_provide -Requires: python-srpm-macros - -%description -This package contains the unversioned Python RPM macros, that most -implementations should rely on. - -You should not need to install this package manually as the various -python?-devel packages require it. So install a python-devel package instead. - -%package -n python-srpm-macros -Summary: RPM macros for building Python source packages - -%description -n python-srpm-macros -RPM macros for building Python source packages. - -%package -n python2-rpm-macros -Summary: RPM macros for building Python 2 packages - -%description -n python2-rpm-macros -RPM macros for building Python 2 packages. - -%package -n python3-rpm-macros -Summary: RPM macros for building Python 3 packages - -%description -n python3-rpm-macros -RPM macros for building Python 3 packages. - - -%prep - -%build - -%install -mkdir -p %{buildroot}/%{rpmmacrodir} -install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} \ - %{buildroot}/%{rpmmacrodir}/ - - -%files -%{rpmmacrodir}/macros.python -%{rpmmacrodir}/macros.pybytecompile - -%files -n python-srpm-macros -%{rpmmacrodir}/macros.python-srpm - -%files -n python2-rpm-macros -%{rpmmacrodir}/macros.python2 - -%files -n python3-rpm-macros -%{rpmmacrodir}/macros.python3 - - -%changelog -* Tue Apr 30 2019 Miro Hrončok - 3-25 -- Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros - -* Thu Apr 25 2019 Miro Hrončok - 3-24 -- %%python_provide: Obsolete and provide python36- from python3- -- %%python_provide: Provide python3- from python36- - -* Thu Jan 31 2019 Miro Hrončok - 3-23 -- Make Python 3.6 the main Python 3 version -- Make Python 3.4 the other Python 3 version - -* Sat Jul 14 2018 Tomas Orsava - 3-22 -- Move macros.pybytecompile in here from python3X-devel -- macros.pybytecompile: Detect Python version through sys.version_info instead - of guessing from the executable name - -* Mon Jul 09 2018 Jason L Tibbitts III - 3-21 -- Backport %%python3_platform and add %%python3_other_platform. - -* Thu Jun 21 2018 Tadej Janež - 3-20 -- Add %%python3_other_* counterparts for %%python3_* macros in EPEL 7 - -* Mon Jun 18 2018 Jason L Tibbitts III - 3-19 -- Add %%pypi_source macro. - -* Wed Dec 20 2017 Charalampos Stratakis - 3-18 -- Add python36 in EPEL 7. - -* 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 - -* Thu Nov 24 2016 Orion Poplawski 3-15 -- 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) - -* 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 -- Tidy up macro formatting - -* Wed Aug 24 2016 Orion Poplawski 3-11 -- Use %%rpmmacrodir - -* Tue Jul 12 2016 Orion Poplawski 3-10 -- Do not generate useless Obsoletes with %%{?_isa} - -* Fri May 13 2016 Orion Poplawski 3-9 -- Make python-rpm-macros require python-srpm-macros (bug #1335860) - -* Thu May 12 2016 Jason L Tibbitts III - 3-8 -- Add single-second sleeps to work around setuptools bug. - -* Thu Feb 04 2016 Fedora Release Engineering - 3-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - -* Mon Jan 25 2016 Orion Poplawski 3-6.1 -- Set %%__python3 to /usr/bin/python3.4 - -* Thu Jan 14 2016 Orion Poplawski 3-6 -- Fix typo in %%python_provide - -* Thu Jan 14 2016 Orion Poplawski 3-5 -- Handle noarch python sub-packages (bug #1290900) - -* Thu Jan 14 2016 Orion Poplawski 3-4.1 -- EPEL version - -* Wed Jan 13 2016 Orion Poplawski 3-4 -- Fix python2/3-rpm-macros package names - -* Thu Jan 7 2016 Orion Poplawski 3-3 -- Add empty %%prep and %%build - -* Mon Jan 4 2016 Orion Poplawski 3-2 -- Combined package - -* Wed Dec 30 2015 Orion Poplawski 3-1 -- Initial package diff --git a/sources b/sources deleted file mode 100644 index e69de29..0000000 From 0c6d6cedbb591d11b01bb3a191c4905c29353983 Mon Sep 17 00:00:00 2001 From: Mohan Boddu Date: Sun, 11 Aug 2019 03:48:56 -0400 Subject: [PATCH 13/15] Revert "Included in RHEL 7.7+" Unretirement for https://pagure.io/releng/issue/8607 This reverts commit b6f2fa0c7616565c964e5c72ecfddb6e712c2266. --- .gitignore | 0 dead.package | 1 - macros.pybytecompile | 27 +++++++ macros.python | 94 +++++++++++++++++++++++++ macros.python-srpm | 108 ++++++++++++++++++++++++++++ macros.python2 | 37 ++++++++++ macros.python3 | 40 +++++++++++ python-rpm-macros.spec | 156 +++++++++++++++++++++++++++++++++++++++++ sources | 0 9 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 dead.package create mode 100644 macros.pybytecompile create mode 100644 macros.python create mode 100644 macros.python-srpm create mode 100644 macros.python2 create mode 100644 macros.python3 create mode 100644 python-rpm-macros.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/dead.package b/dead.package deleted file mode 100644 index 7d96bd7..0000000 --- a/dead.package +++ /dev/null @@ -1 +0,0 @@ -Included in RHEL 7.7+ diff --git a/macros.pybytecompile b/macros.pybytecompile new file mode 100644 index 0000000..f5439cf --- /dev/null +++ b/macros.pybytecompile @@ -0,0 +1,27 @@ +# Note that the path could itself be a python file, or a directory + +# Python's compile_all module only works on directories, and requires a max +# recursion depth + +# Note that the py_byte_compile macro should work for all Python versions +# Which unfortunately makes the definition more complicated than it should be + +%py_byte_compile()\ +py2_byte_compile () {\ + python_binary="%1"\ + bytecode_compilation_path="%2"\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ +}\ +\ +py3_byte_compile () {\ + python_binary="%1"\ + bytecode_compilation_path="%2"\ + find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2], optimize=opt) for opt in range(2) for f in sys.argv[1:]]' || :\ +}\ +\ +# Get version without a dot (36 instead of 3.6), bash doesn't compare floats well \ +python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \ +# The bytecompilation syntax has changed between Python 3.4 and Python 3.5, so for 3.4 and earlier we use the "Python 2" syntax \ +[ "$python_version" -ge 35 ] && py3_byte_compile "%1" "%2" || py2_byte_compile "%1" "%2" \ +%{nil} diff --git a/macros.python b/macros.python new file mode 100644 index 0000000..37961b0 --- /dev/null +++ b/macros.python @@ -0,0 +1,94 @@ +%py_setup setup.py +%py_shbang_opts -s + +# 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:\\\ + 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:\\\ + 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, "python3-")) then + if (rpm.expand("%{?buildarch}") ~= "noarch") then + str = "Provides: python36-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr + print(rpm.expand(str)) + end + print("\\nProvides: python36-") + print(string.sub(package,9,string.len(package))) + print(" = ") + print(vr) + --Obsoleting the EPEL python36 package + print("\\nObsoletes: python36-") + print(string.sub(package,9,string.len(package))) + print(" < ") + print(vr) + elseif (string.starts(package, "python36-")) then + if (rpm.expand("%{?buildarch}") ~= "noarch") then + str = "Provides: python3-" .. string.sub(package,10,string.len(package)) .. "%{?_isa} = " .. vr + print(rpm.expand(str)) + end + print("\\nProvides: python3-") + print(string.sub(package,10,string.len(package))) + print(" = ") + print(vr) + 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.python-srpm b/macros.python-srpm new file mode 100644 index 0000000..92193f8 --- /dev/null +++ b/macros.python-srpm @@ -0,0 +1,108 @@ +# python3_pkgversion specifies the version of Python 3 in the distro. It can be +# a specific version (e.g. 36 in Fedora EPEL7) +%python3_pkgversion 36 +%python3_other_pkgversion 34 + +# Set to /bin/true when not active to avoid %ifdefs and %{? in specfiles +%__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\ +} + +# Macro to replace overly complicated references to PyPI source files. +# Expands to the pythonhosted URL for a package +# Accepts zero to three arguments: +# 1: The PyPI project name, defaulting to %srcname if it is defined, then +# %pypi_name if it is defined, then just %name. +# 2: The PYPI version, defaulting to %version. +# 3: The file extension, defaulting to "tar.gz". (A period will be added +# automatically.) +# Requires %__pypi_url and %__pypi_default_extension to be defined. +%__pypi_url https://files.pythonhosted.org/packages/source/ +%__pypi_default_extension tar.gz + +%pypi_source() %{lua: + local src = rpm.expand('%1') + local ver = rpm.expand('%2') + local ext = rpm.expand('%3') + local url = rpm.expand('%__pypi_url') +\ + -- If no first argument, try %srcname, then %pypi_name, then %name + -- Note that rpm leaves macros unchanged if they are not defined. + if src == '%1' then + src = rpm.expand('%srcname') + end + if src == '%srcname' then + src = rpm.expand('%pypi_name') + end + if src == '%pypi_name' then + src = rpm.expand('%name') + end +\ + -- If no second argument, use %version + if ver == '%2' then + ver = rpm.expand('%version') + end +\ + -- If no third argument, use the preset default extension + if ext == '%3' then + ext = rpm.expand('%__pypi_default_extension') + end +\ + local first = string.sub(src, 1, 1) +\ + print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext) +} diff --git a/macros.python2 b/macros.python2 new file mode 100644 index 0000000..169d48f --- /dev/null +++ b/macros.python2 @@ -0,0 +1,37 @@ +%__python2 /usr/bin/python2 +%python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") +%python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") +%python2_version %(%{__python2} -c "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") +%python2_version_nodots %(%{__python2} -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") + +%py2_shbang_opts -s + +# 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:\\\ + 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 new file mode 100644 index 0000000..242e72a --- /dev/null +++ b/macros.python3 @@ -0,0 +1,40 @@ +%__python3 /usr/bin/python3.6 + +%python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") +%python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") +%python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])") +%python3_version_nodots %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") +%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") +%py3dir %{_builddir}/python3-%{name}-%{version}-%{release} + +%py3_shbang_opts -s + +# 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:\\\ + 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 new file mode 100644 index 0000000..5274291 --- /dev/null +++ b/python-rpm-macros.spec @@ -0,0 +1,156 @@ +Name: python-rpm-macros +Version: 3 +Release: 25%{?dist} +Summary: The unversioned Python RPM macros + +License: MIT +Source0: macros.python +Source1: macros.python-srpm +Source2: macros.python2 +Source3: macros.python3 +Source5: macros.pybytecompile + +BuildArch: noarch +# For %%python3_pkgversion used in %%python_provide +Requires: python-srpm-macros + +%description +This package contains the unversioned Python RPM macros, that most +implementations should rely on. + +You should not need to install this package manually as the various +python?-devel packages require it. So install a python-devel package instead. + +%package -n python-srpm-macros +Summary: RPM macros for building Python source packages + +%description -n python-srpm-macros +RPM macros for building Python source packages. + +%package -n python2-rpm-macros +Summary: RPM macros for building Python 2 packages + +%description -n python2-rpm-macros +RPM macros for building Python 2 packages. + +%package -n python3-rpm-macros +Summary: RPM macros for building Python 3 packages + +%description -n python3-rpm-macros +RPM macros for building Python 3 packages. + + +%prep + +%build + +%install +mkdir -p %{buildroot}/%{rpmmacrodir} +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} \ + %{buildroot}/%{rpmmacrodir}/ + + +%files +%{rpmmacrodir}/macros.python +%{rpmmacrodir}/macros.pybytecompile + +%files -n python-srpm-macros +%{rpmmacrodir}/macros.python-srpm + +%files -n python2-rpm-macros +%{rpmmacrodir}/macros.python2 + +%files -n python3-rpm-macros +%{rpmmacrodir}/macros.python3 + + +%changelog +* Tue Apr 30 2019 Miro Hrončok - 3-25 +- Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros + +* Thu Apr 25 2019 Miro Hrončok - 3-24 +- %%python_provide: Obsolete and provide python36- from python3- +- %%python_provide: Provide python3- from python36- + +* Thu Jan 31 2019 Miro Hrončok - 3-23 +- Make Python 3.6 the main Python 3 version +- Make Python 3.4 the other Python 3 version + +* Sat Jul 14 2018 Tomas Orsava - 3-22 +- Move macros.pybytecompile in here from python3X-devel +- macros.pybytecompile: Detect Python version through sys.version_info instead + of guessing from the executable name + +* Mon Jul 09 2018 Jason L Tibbitts III - 3-21 +- Backport %%python3_platform and add %%python3_other_platform. + +* Thu Jun 21 2018 Tadej Janež - 3-20 +- Add %%python3_other_* counterparts for %%python3_* macros in EPEL 7 + +* Mon Jun 18 2018 Jason L Tibbitts III - 3-19 +- Add %%pypi_source macro. + +* Wed Dec 20 2017 Charalampos Stratakis - 3-18 +- Add python36 in EPEL 7. + +* 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 + +* Thu Nov 24 2016 Orion Poplawski 3-15 +- 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) + +* 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 +- Tidy up macro formatting + +* Wed Aug 24 2016 Orion Poplawski 3-11 +- Use %%rpmmacrodir + +* Tue Jul 12 2016 Orion Poplawski 3-10 +- Do not generate useless Obsoletes with %%{?_isa} + +* Fri May 13 2016 Orion Poplawski 3-9 +- Make python-rpm-macros require python-srpm-macros (bug #1335860) + +* Thu May 12 2016 Jason L Tibbitts III - 3-8 +- Add single-second sleeps to work around setuptools bug. + +* Thu Feb 04 2016 Fedora Release Engineering - 3-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Mon Jan 25 2016 Orion Poplawski 3-6.1 +- Set %%__python3 to /usr/bin/python3.4 + +* Thu Jan 14 2016 Orion Poplawski 3-6 +- Fix typo in %%python_provide + +* Thu Jan 14 2016 Orion Poplawski 3-5 +- Handle noarch python sub-packages (bug #1290900) + +* Thu Jan 14 2016 Orion Poplawski 3-4.1 +- EPEL version + +* Wed Jan 13 2016 Orion Poplawski 3-4 +- Fix python2/3-rpm-macros package names + +* Thu Jan 7 2016 Orion Poplawski 3-3 +- Add empty %%prep and %%build + +* Mon Jan 4 2016 Orion Poplawski 3-2 +- Combined package + +* Wed Dec 30 2015 Orion Poplawski 3-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..e69de29 From 82adee866757c2f804b1c6bb76f5ecde538af7f6 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Wed, 14 Aug 2019 08:05:31 -0700 Subject: [PATCH 14/15] Update to larger than 30 so rhel7.7 python2 will work in koji. Note: this package should be retired as soon as centos 7.7 is out. Note: this package should NOT be pushed as an update, only used as a override. --- 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 5274291..101a116 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -1,6 +1,6 @@ Name: python-rpm-macros Version: 3 -Release: 25%{?dist} +Release: 31%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -65,6 +65,11 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} \ %changelog +* Wed Aug 14 2019 Kevin Fenzi - 3-31 +- Update to larger than 30 so rhel7.7 python2 will work in koji. +- Note: this package should be retired as soon as centos 7.7 is out. +- Note: this package should NOT be pushed as an update, only used as a override. + * Tue Apr 30 2019 Miro Hrončok - 3-25 - Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros From 99a8a3e31e3a51b26cd28828254d44e9b3f1407f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 7 Oct 2019 19:10:57 +0200 Subject: [PATCH 15/15] Included in RHEL 7.7+ --- .gitignore | 0 dead.package | 1 + macros.pybytecompile | 27 ------- macros.python | 94 ------------------------ macros.python-srpm | 108 --------------------------- macros.python2 | 37 ---------- macros.python3 | 40 ---------- python-rpm-macros.spec | 161 ----------------------------------------- sources | 0 9 files changed, 1 insertion(+), 467 deletions(-) delete mode 100644 .gitignore create mode 100644 dead.package delete mode 100644 macros.pybytecompile delete mode 100644 macros.python delete mode 100644 macros.python-srpm delete mode 100644 macros.python2 delete mode 100644 macros.python3 delete mode 100644 python-rpm-macros.spec delete mode 100644 sources diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/dead.package b/dead.package new file mode 100644 index 0000000..7d96bd7 --- /dev/null +++ b/dead.package @@ -0,0 +1 @@ +Included in RHEL 7.7+ diff --git a/macros.pybytecompile b/macros.pybytecompile deleted file mode 100644 index f5439cf..0000000 --- a/macros.pybytecompile +++ /dev/null @@ -1,27 +0,0 @@ -# Note that the path could itself be a python file, or a directory - -# Python's compile_all module only works on directories, and requires a max -# recursion depth - -# Note that the py_byte_compile macro should work for all Python versions -# Which unfortunately makes the definition more complicated than it should be - -%py_byte_compile()\ -py2_byte_compile () {\ - python_binary="%1"\ - bytecode_compilation_path="%2"\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2]) for f in sys.argv[1:]]' || :\ -}\ -\ -py3_byte_compile () {\ - python_binary="%1"\ - bytecode_compilation_path="%2"\ - find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2], optimize=opt) for opt in range(2) for f in sys.argv[1:]]' || :\ -}\ -\ -# Get version without a dot (36 instead of 3.6), bash doesn't compare floats well \ -python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \ -# The bytecompilation syntax has changed between Python 3.4 and Python 3.5, so for 3.4 and earlier we use the "Python 2" syntax \ -[ "$python_version" -ge 35 ] && py3_byte_compile "%1" "%2" || py2_byte_compile "%1" "%2" \ -%{nil} diff --git a/macros.python b/macros.python deleted file mode 100644 index 37961b0..0000000 --- a/macros.python +++ /dev/null @@ -1,94 +0,0 @@ -%py_setup setup.py -%py_shbang_opts -s - -# 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:\\\ - 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:\\\ - 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, "python3-")) then - if (rpm.expand("%{?buildarch}") ~= "noarch") then - str = "Provides: python36-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr - print(rpm.expand(str)) - end - print("\\nProvides: python36-") - print(string.sub(package,9,string.len(package))) - print(" = ") - print(vr) - --Obsoleting the EPEL python36 package - print("\\nObsoletes: python36-") - print(string.sub(package,9,string.len(package))) - print(" < ") - print(vr) - elseif (string.starts(package, "python36-")) then - if (rpm.expand("%{?buildarch}") ~= "noarch") then - str = "Provides: python3-" .. string.sub(package,10,string.len(package)) .. "%{?_isa} = " .. vr - print(rpm.expand(str)) - end - print("\\nProvides: python3-") - print(string.sub(package,10,string.len(package))) - print(" = ") - print(vr) - 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.python-srpm b/macros.python-srpm deleted file mode 100644 index 92193f8..0000000 --- a/macros.python-srpm +++ /dev/null @@ -1,108 +0,0 @@ -# python3_pkgversion specifies the version of Python 3 in the distro. It can be -# a specific version (e.g. 36 in Fedora EPEL7) -%python3_pkgversion 36 -%python3_other_pkgversion 34 - -# Set to /bin/true when not active to avoid %ifdefs and %{? in specfiles -%__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\ -} - -# Macro to replace overly complicated references to PyPI source files. -# Expands to the pythonhosted URL for a package -# Accepts zero to three arguments: -# 1: The PyPI project name, defaulting to %srcname if it is defined, then -# %pypi_name if it is defined, then just %name. -# 2: The PYPI version, defaulting to %version. -# 3: The file extension, defaulting to "tar.gz". (A period will be added -# automatically.) -# Requires %__pypi_url and %__pypi_default_extension to be defined. -%__pypi_url https://files.pythonhosted.org/packages/source/ -%__pypi_default_extension tar.gz - -%pypi_source() %{lua: - local src = rpm.expand('%1') - local ver = rpm.expand('%2') - local ext = rpm.expand('%3') - local url = rpm.expand('%__pypi_url') -\ - -- If no first argument, try %srcname, then %pypi_name, then %name - -- Note that rpm leaves macros unchanged if they are not defined. - if src == '%1' then - src = rpm.expand('%srcname') - end - if src == '%srcname' then - src = rpm.expand('%pypi_name') - end - if src == '%pypi_name' then - src = rpm.expand('%name') - end -\ - -- If no second argument, use %version - if ver == '%2' then - ver = rpm.expand('%version') - end -\ - -- If no third argument, use the preset default extension - if ext == '%3' then - ext = rpm.expand('%__pypi_default_extension') - end -\ - local first = string.sub(src, 1, 1) -\ - print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext) -} diff --git a/macros.python2 b/macros.python2 deleted file mode 100644 index 169d48f..0000000 --- a/macros.python2 +++ /dev/null @@ -1,37 +0,0 @@ -%__python2 /usr/bin/python2 -%python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -%python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%python2_version %(%{__python2} -c "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))") -%python2_version_nodots %(%{__python2} -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") - -%py2_shbang_opts -s - -# 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:\\\ - 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 deleted file mode 100644 index 242e72a..0000000 --- a/macros.python3 +++ /dev/null @@ -1,40 +0,0 @@ -%__python3 /usr/bin/python3.6 - -%python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -%python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") -%python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])") -%python3_version_nodots %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3].replace('.',''))") -%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())") -%py3dir %{_builddir}/python3-%{name}-%{version}-%{release} - -%py3_shbang_opts -s - -# 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:\\\ - 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 deleted file mode 100644 index 101a116..0000000 --- a/python-rpm-macros.spec +++ /dev/null @@ -1,161 +0,0 @@ -Name: python-rpm-macros -Version: 3 -Release: 31%{?dist} -Summary: The unversioned Python RPM macros - -License: MIT -Source0: macros.python -Source1: macros.python-srpm -Source2: macros.python2 -Source3: macros.python3 -Source5: macros.pybytecompile - -BuildArch: noarch -# For %%python3_pkgversion used in %%python_provide -Requires: python-srpm-macros - -%description -This package contains the unversioned Python RPM macros, that most -implementations should rely on. - -You should not need to install this package manually as the various -python?-devel packages require it. So install a python-devel package instead. - -%package -n python-srpm-macros -Summary: RPM macros for building Python source packages - -%description -n python-srpm-macros -RPM macros for building Python source packages. - -%package -n python2-rpm-macros -Summary: RPM macros for building Python 2 packages - -%description -n python2-rpm-macros -RPM macros for building Python 2 packages. - -%package -n python3-rpm-macros -Summary: RPM macros for building Python 3 packages - -%description -n python3-rpm-macros -RPM macros for building Python 3 packages. - - -%prep - -%build - -%install -mkdir -p %{buildroot}/%{rpmmacrodir} -install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE5} \ - %{buildroot}/%{rpmmacrodir}/ - - -%files -%{rpmmacrodir}/macros.python -%{rpmmacrodir}/macros.pybytecompile - -%files -n python-srpm-macros -%{rpmmacrodir}/macros.python-srpm - -%files -n python2-rpm-macros -%{rpmmacrodir}/macros.python2 - -%files -n python3-rpm-macros -%{rpmmacrodir}/macros.python3 - - -%changelog -* Wed Aug 14 2019 Kevin Fenzi - 3-31 -- Update to larger than 30 so rhel7.7 python2 will work in koji. -- Note: this package should be retired as soon as centos 7.7 is out. -- Note: this package should NOT be pushed as an update, only used as a override. - -* Tue Apr 30 2019 Miro Hrončok - 3-25 -- Split python3-other-rpm-macros from python-rpm-macros to python-epel-rpm-macros - -* Thu Apr 25 2019 Miro Hrončok - 3-24 -- %%python_provide: Obsolete and provide python36- from python3- -- %%python_provide: Provide python3- from python36- - -* Thu Jan 31 2019 Miro Hrončok - 3-23 -- Make Python 3.6 the main Python 3 version -- Make Python 3.4 the other Python 3 version - -* Sat Jul 14 2018 Tomas Orsava - 3-22 -- Move macros.pybytecompile in here from python3X-devel -- macros.pybytecompile: Detect Python version through sys.version_info instead - of guessing from the executable name - -* Mon Jul 09 2018 Jason L Tibbitts III - 3-21 -- Backport %%python3_platform and add %%python3_other_platform. - -* Thu Jun 21 2018 Tadej Janež - 3-20 -- Add %%python3_other_* counterparts for %%python3_* macros in EPEL 7 - -* Mon Jun 18 2018 Jason L Tibbitts III - 3-19 -- Add %%pypi_source macro. - -* Wed Dec 20 2017 Charalampos Stratakis - 3-18 -- Add python36 in EPEL 7. - -* 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 - -* Thu Nov 24 2016 Orion Poplawski 3-15 -- 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) - -* 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 -- Tidy up macro formatting - -* Wed Aug 24 2016 Orion Poplawski 3-11 -- Use %%rpmmacrodir - -* Tue Jul 12 2016 Orion Poplawski 3-10 -- Do not generate useless Obsoletes with %%{?_isa} - -* Fri May 13 2016 Orion Poplawski 3-9 -- Make python-rpm-macros require python-srpm-macros (bug #1335860) - -* Thu May 12 2016 Jason L Tibbitts III - 3-8 -- Add single-second sleeps to work around setuptools bug. - -* Thu Feb 04 2016 Fedora Release Engineering - 3-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - -* Mon Jan 25 2016 Orion Poplawski 3-6.1 -- Set %%__python3 to /usr/bin/python3.4 - -* Thu Jan 14 2016 Orion Poplawski 3-6 -- Fix typo in %%python_provide - -* Thu Jan 14 2016 Orion Poplawski 3-5 -- Handle noarch python sub-packages (bug #1290900) - -* Thu Jan 14 2016 Orion Poplawski 3-4.1 -- EPEL version - -* Wed Jan 13 2016 Orion Poplawski 3-4 -- Fix python2/3-rpm-macros package names - -* Thu Jan 7 2016 Orion Poplawski 3-3 -- Add empty %%prep and %%build - -* Mon Jan 4 2016 Orion Poplawski 3-2 -- Combined package - -* Wed Dec 30 2015 Orion Poplawski 3-1 -- Initial package diff --git a/sources b/sources deleted file mode 100644 index e69de29..0000000