From ec28c775cd316c322aa31826e0e3f5c9f03812a9 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Jan 12 2016 23:52:28 +0000 Subject: Initial import --- diff --git a/macros.python b/macros.python new file mode 100644 index 0000000..4a5cb2a --- /dev/null +++ b/macros.python @@ -0,0 +1,54 @@ +%py_setup setup.py +%py_shbang_opts -s + +%py_build() %{expand:\ +CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?1}\ +} + +%py_install() %{expand:\ +CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +} + +%python_provide() %{lua:\ + function string.starts(String,Start)\ + return string.sub(String,1,string.len(Start))==Start\ + end\ + package = rpm.expand("%{?1:%{1}}");\ + vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}") + if (string.starts(package, "python2-")) then\ + str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr;\ + print(rpm.expand(str));\ + print("\\nProvides: python-");\ + print(string.sub(package,9,string.len(package)));\ + print(" = ");\ + print(vr);\ + --Obsoleting the previous default python package\ + str = "\\nObsoletes: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} < " .. vr;\ + print(rpm.expand(str));\ + print("\\nObsoletes: python-");\ + print(string.sub(package,9,string.len(package)));\ + print(" < ");\ + print(vr);\ + elseif (string.starts(package, "python3-")) then\ + --No unversioned provides as python3 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("ERROR: ");\ + print(package);\ + 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 diff --git a/macros.python-srpm b/macros.python-srpm new file mode 100644 index 0000000..4257beb --- /dev/null +++ b/macros.python-srpm @@ -0,0 +1,3 @@ +# 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 diff --git a/macros.python2 b/macros.python2 new file mode 100644 index 0000000..6bfd7f8 --- /dev/null +++ b/macros.python2 @@ -0,0 +1,15 @@ +%__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 + +%py2_build() %{expand:\ +CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?1}\ +} + +%py2_install() %{expand:\ +CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +} diff --git a/macros.python3 b/macros.python3 new file mode 100644 index 0000000..a633c72 --- /dev/null +++ b/macros.python3 @@ -0,0 +1,16 @@ +%__python3 /usr/bin/python3 +%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('.',''))") +%py3dir %{_builddir}/python3-%{name}-%{version}-%{release} + +%py3_shbang_opts -s + +%py3_build() %{expand:\ +CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?1}\ +} + +%py3_install() %{expand:\ +CFLAGS="%{optflags}" %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\ +} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec new file mode 100644 index 0000000..6678085 --- /dev/null +++ b/python-rpm-macros.spec @@ -0,0 +1,77 @@ +Name: python-rpm-macros +Version: 3 +Release: 3%{?dist} +Summary: The unversioned Python RPM macros + +License: MIT +Source0: macros.python +Source1: macros.python-srpm +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 +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-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-macros +RPM macros for building Python 2 packages. + +%package -n python3-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-macros +RPM macros for building Python 3 packages. + + +%prep + +%build + +%install +mkdir -p %{buildroot}/%{_rpmconfigdir}/macros.d/ +install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \ + %{buildroot}/%{_rpmconfigdir}/macros.d/ + + +%files +%{_rpmconfigdir}/macros.d/macros.python + +%files -n python-srpm-macros +%{_rpmconfigdir}/macros.d/macros.python-srpm + +%files -n python2-macros +%{_rpmconfigdir}/macros.d/macros.python2 + +%files -n python3-macros +%{_rpmconfigdir}/macros.d/macros.python3 + + +%changelog +* Thu Jan 8 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