From 910a7dfd4da9ff09c8f98d26a449958947a1f2ba Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 19 Jan 2018 15:37:47 +0100 Subject: [PATCH 1/4] add macros to enable dependency generator References: https://fedoraproject.org/wiki/Changes/EnablingPythonGenerators Signed-off-by: Igor Gnatenko (cherry picked from commit ec476c84cc342ef1a1b6bb5a87134a3f50fb2930) --- macros.python | 4 ++++ python-rpm-macros.spec | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/macros.python b/macros.python index 8b168b5..7c0f058 100644 --- a/macros.python +++ b/macros.python @@ -71,3 +71,7 @@ print(" not recognized.") end } + +%python_enable_dependency_generator() \ +%global __python_requires %{_rpmconfigdir}/pythondistdeps.py --requires \ +%{nil} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index dcd121b..347cb95 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 @@ -77,8 +77,10 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %files -n platform-python-rpm-macros %{rpmmacrodir}/macros.platform-python - %changelog +* Fri Jan 19 2018 Igor Gnatenko - 3-25 +- Add %%python_enable_dependency_generator + * Thu Oct 26 2017 Ville Skyttä - 3-23 - Use -Es/-I to invoke macro scriptlets (#1506355) From a299eaadad1bb469e10457bba09d9b0504225111 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Mon, 18 Jun 2018 17:54:00 -0500 Subject: [PATCH 2/4] Add %pypi_source macro. Also fixed typo in changelog version from previous commit. --- macros.python-srpm | 44 ++++++++++++++++++++++++++++++++++++++++++ python-rpm-macros.spec | 7 +++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/macros.python-srpm b/macros.python-srpm index 38a71dc..9016032 100644 --- a/macros.python-srpm +++ b/macros.python-srpm @@ -61,3 +61,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 347cb95..005f850 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 @@ -78,7 +78,10 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %{rpmmacrodir}/macros.platform-python %changelog -* Fri Jan 19 2018 Igor Gnatenko - 3-25 +* Mon Jun 18 2018 Jason L Tibbitts III - 3-25 +- Add %%pypi_source macro. + +* Fri Jan 19 2018 Igor Gnatenko - 3-24 - Add %%python_enable_dependency_generator * Thu Oct 26 2017 Ville Skyttä - 3-23 From 82dab566961c5cac739187762ef793d7df78825b Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Mon, 9 Jul 2018 14:24:20 -0500 Subject: [PATCH 3/4] Add %python3_platform macro. --- macros.python3 | 1 + 1 file changed, 1 insertion(+) diff --git a/macros.python3 b/macros.python3 index dc15710..e626482 100644 --- a/macros.python3 +++ b/macros.python3 @@ -3,6 +3,7 @@ %python3_sitearch %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") %python3_version %(%{__python3} -Ic "import sys; sys.stdout.write(sys.version[:3])") %python3_version_nodots %(%{__python3} -Ic "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 From bc98f14c5d83eb2544a89a51cd47ebeb0d2201d7 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Mon, 9 Jul 2018 14:30:00 -0500 Subject: [PATCH 4/4] Update specfile. --- python-rpm-macros.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 005f850..d74a746 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: 26%{?dist} Summary: The unversioned Python RPM macros License: MIT @@ -78,6 +78,9 @@ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ %{rpmmacrodir}/macros.platform-python %changelog +* Mon Jul 09 2018 Jason L Tibbitts III - 3-26 +- Backport %%python3_platform macro. + * Mon Jun 18 2018 Jason L Tibbitts III - 3-25 - Add %%pypi_source macro.