From f245b70862ef2763fa41e71fc834afbc02fac0e6 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 11:08:59 +0000 Subject: import python-rpm-macros-3-32.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.gitignore diff --git a/.python-rpm-macros.metadata b/.python-rpm-macros.metadata new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.python-rpm-macros.metadata diff --git a/SOURCES/macros.pybytecompile b/SOURCES/macros.pybytecompile new file mode 100644 index 0000000..d06071e --- /dev/null +++ b/SOURCES/macros.pybytecompile @@ -0,0 +1,24 @@ +# 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 + +# Usage: +# %py_byte_compile +# Example: +# %py_byte_compile %{__python3} %{buildroot}%{_datadir}/spam/plugins/ + +# This will terminate build on SyntaxErrors, if you want to avoid that, +# use it in a subshell like this: +# (%{py_byte_compile }) || : + +%py_byte_compile()\ +python_binary="%1"\ +buildroot_path="%2"\ +bytecode_compilation_path=".${buildroot_path/#$RPM_BUILD_ROOT}"\ +failure=0\ +pushd $RPM_BUILD_ROOT\ +find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -m py_compile || failure=1\ +find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -m py_compile || failure=1\ +popd\ +test $failure -eq 0 diff --git a/SOURCES/macros.python b/SOURCES/macros.python new file mode 100644 index 0000000..37961b0 --- /dev/null +++ b/SOURCES/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/SOURCES/macros.python-srpm b/SOURCES/macros.python-srpm new file mode 100644 index 0000000..c4bdd1c --- /dev/null +++ b/SOURCES/macros.python-srpm @@ -0,0 +1,107 @@ +# 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 + +# Set to /bin/true 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/SOURCES/macros.python2 b/SOURCES/macros.python2 new file mode 100644 index 0000000..169d48f --- /dev/null +++ b/SOURCES/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/SOURCES/macros.python3 b/SOURCES/macros.python3 new file mode 100644 index 0000000..25c6f62 --- /dev/null +++ b/SOURCES/macros.python3 @@ -0,0 +1,43 @@ +%__python3 /usr/bin/python3 +%python3_sitelib %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib())") +%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 + +# Use the slashes after expand so that the command starts on the same line as +# the macro +%py3_build() %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*} + sleep 1 +} + +%py3_build_egg() %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + %{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*} + sleep 1 +} + +%py3_build_wheel() %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + %{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*} + sleep 1 +} + +%py3_install() %{expand:\\\ + CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\ + %{__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/SPECS/python-rpm-macros.spec b/SPECS/python-rpm-macros.spec new file mode 100644 index 0000000..18bfdc6 --- /dev/null +++ b/SPECS/python-rpm-macros.spec @@ -0,0 +1,187 @@ +%global rpmmacrodir %{_sysconfdir}/rpm + +Name: python-rpm-macros +Version: 3 +Release: 32%{?dist} +Summary: The unversioned Python RPM macros + +License: MIT +Source0: macros.python +Source1: macros.python-srpm +Source2: macros.python2 +Source3: macros.python3 +Source4: macros.pybytecompile + +BuildArch: noarch +# The macro file has been moved from the python-devel package +Conflicts: python-devel < 2.7.5-78 +# 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 +# The macro file has been moved from the python-devel package +Conflicts: python-devel < 2.7.5-78 + +%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. + + +%prep + +%build + +%install +mkdir -p %{buildroot}/%{_sysconfdir}/rpm +mkdir -p %{buildroot}/%{rpmmacrodir} +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \ + %{buildroot}/%{_sysconfdir}/rpm/ + + +%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 Apr 24 2019 Miro Hrončok - 3-32 +- %%python_provide: Obsolete and provide python36- from python3- +- %%python_provide: Provide python3- from python36- +Resolves: rhbz#1702719 + +* Mon Jan 14 2019 Lumír Balhar - 3-31 +- Converting specfile from F28 to RHEL7 +- Move the macros to the standard RHEL7 macro location at /etc/rpm/, + instead of Fedora's location at /usr/lib/rpm/macros.d/ +- Import the macros.python{,2} files from the python-devel package where they + resided until now, and Conflict with that old version of python-devel +- Import the macros.pybytecompile from Fedora rawhide / RHEL8 +Resolves: rhbz#1660579 + +* Mon Jul 09 2018 Jason L Tibbitts III - 3-30 +- Backport %%python3_platform macro. + +* Mon Jun 18 2018 Jason L Tibbitts III - 3-29 +- Add %%pypi_source macro. + +* Fri Apr 06 2018 Tomas Orsava - 3-28 +- Fix the %%py_dist_name macro to not convert dots (".") into dashes, so that + submodules can be addressed as well Resolves: rhbz#1564095 + +* Fri Mar 23 2018 Miro Hrončok - 3-27 +- make LDFLAGS propagated whenever CFLAGS are + +* Fri Feb 09 2018 Fedora Release Engineering - 3-26 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Fri Jan 19 2018 Igor Gnatenko - 3-25 +- Add %%python_enable_dependency_generator + +* Tue Nov 28 2017 Tomas Orsava - 3-24 +- Remove platform-python macros (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack) + +* Thu Oct 26 2017 Ville Skyttä - 3-23 +- Use -Es/-I to invoke macro scriptlets (#1506355) + +* Wed Aug 02 2017 Tomas Orsava - 3-22 +- Add platform-python macros (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack) + +* Thu Jul 27 2017 Fedora Release Engineering - 3-21 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Mar 03 2017 Michal Cyprian - 3-20 +- Revert "Switch %%__python3 to /usr/libexec/system-python" + after the Fedora Change https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe + was postponed + +* Fri Feb 17 2017 Michal Cyprian - 3-19 +- Switch %%__python3 to /usr/libexec/system-python + +* Sat Feb 11 2017 Fedora Release Engineering - 3-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* 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 + +* 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) + +* 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