#2 Fix python packaging violations detected by taskotron
Merged 6 years ago by rohanpm. Opened 6 years ago by rohanpm.
rpms/ rohanpm/kobo master  into  master

file modified
+42 -12
@@ -41,10 +41,21 @@ 

  %define with_hub 0

  %endif

  

+ # Use the python2-* packages for dependencies if possible,

+ # as suggested by Fedora packaging guidelines; but these aren't

+ # available for EPEL builds.

+ %if 0%{?epel}

+ %define python2_django python-django

+ %define python2_rpm    rpm-python

+ %else

+ %define python2_django python2-django

+ %define python2_rpm    python2-rpm

+ %endif

+ 

  

  Name:           kobo

  Version:        0.7.0

- Release:        2%{?dist}

+ Release:        3%{?dist}

  License:        LGPLv2

  Summary:        Python modules for tools development

  Group:          Development/Libraries
@@ -75,7 +86,7 @@ 

  Summary:        Django components

  Group:          Development/Libraries

  Requires:       python2-kobo = %{version}-%{release}

- Requires:       python-django >= 1.6

+ Requires:       %{python2_django} >= 1.6

  %{?python_provide:%python_provide python2-%{name}-django}

  Provides:       kobo-django = %{version}-%{release}

  Obsoletes:      kobo-django < 0.6.0-2
@@ -136,7 +147,7 @@ 

  Summary:        Functions to manipulate with RPM files

  Group:          Development/Libraries

  Requires:       python2-kobo = %{version}-%{release}

- Requires:       rpm-python

+ Requires:       %{python2_rpm}

  Requires:       python2-koji

  %{?python_provide:%python_provide python2-%{name}-rpmlib}

  Provides:       kobo-rpmlib = %{version}-%{release}
@@ -147,18 +158,28 @@ 

  

  

  %if 0%{?with_admin}

+ %package admin

+ Summary:        Kobo admin script for instant project deployment

+ Group:          Development/Tools

+ %if 0%{?with_python3}

+ Requires:       python3-%{name}-admin

+ %else

+ Requires:       python2-%{name}-admin

+ %endif

+ 

+ %description admin

+ Kobo admin provides templates for various kobo-based projects,

+ incl. CLI, hub client, worker and hub.

+ 

  %package -n python2-%{name}-admin

  Summary:        Kobo admin script for instant project deployment

  Group:          Development/Tools

  Requires:       python2-kobo >= %{version}

  Requires:       python2-django >= 1.6

  %{?python_provide:%python_provide python2-%{name}-admin}

- Provides:       kobo-admin = %{version}-%{release}

- Obsoletes:      kobo-admin < 0.6.0-2

  

  %description -n python2-%{name}-admin

- Kobo admin provides templates for various kobo-based projects,

- incl. CLI, hub client, worker and hub.

+ Python library for kobo-admin command.

  %endif

  

  %if 0%{?with_python3}
@@ -225,7 +246,7 @@ 

  Summary:        Functions to manipulate with RPM files

  Group:          Development/Libraries

  Requires:       python%{python3_pkgversion}-kobo = %{version}-%{release}

- Requires:       rpm-python

+ Requires:       python%{python3_pkgversion}-rpm

  Requires:       python%{python3_pkgversion}-koji

  %{?python_provide:%python_provide python%{python3_pkgversion}-%{name}-rpmlib}

  
@@ -242,8 +263,7 @@ 

  %{?python_provide:%python_provide python%{python3_pkgversion}-%{name}-admin}

  

  %description -n python%{python3_pkgversion}-%{name}-admin

- Kobo admin provides templates for various kobo-based projects,

- incl. CLI, hub client, worker and hub.

+ Python library for kobo-admin command.

  %endif

  %endif # with_python3

  
@@ -262,7 +282,10 @@ 

  %install

  rm -rf ${RPM_BUILD_ROOT}

  %{py2_install}

+ 

  %if 0%{?with_python3}

+ # only package python3 version of kobo-admin

+ rm -rf $RPM_BUILD_ROOT/%{_bindir}/kobo-admin

  %{py3_install}

  %endif

  
@@ -343,9 +366,11 @@ 

  

  

  %if 0%{?with_admin}

+ %files admin

+ %{_bindir}/kobo-admin

+ 

  %files -n python2-%{name}-admin

  %{python2_sitelib}/kobo/admin

- %{_bindir}/kobo-admin

  %endif

  

  %if 0%{?with_python3}
@@ -390,12 +415,17 @@ 

  %if 0%{?with_admin}

  %files -n python%{python3_pkgversion}-%{name}-admin

  %{python3_sitelib}/kobo/admin

- %{_bindir}/kobo-admin

  %endif

  %endif

  

  

  %changelog

+ * Wed Oct 18 2017 Rohan McGovern <rmcgover@redhat.com> - 0.7.0-3

+ - Fix duplicate packaging of kobo-admin for python2, python3

+ - Fix some python3 packages depending on python2 packages

+ - Prefer python2-* packages over unprefixed packages for Requires

+ - Move kobo-admin to own package (Lubomír Sedlář)

+ 

  * Wed Oct 18 2017 Rohan McGovern <rmcgover@redhat.com> - 0.7.0-2

  - Fix Provides/Obsoletes to follow packaging guidelines (Lubomír Sedlář)

  

kobo-admin was packaged for both python2 and python3.
According to packaging guidelines, we should prefer to package only the
python3 version.

python3-kobo-rpmlib was wrongly depending on python2 RPM bindings.

python2-kobo-django and python2-kobo-rpmlib should depend on python2-*
packages where possible (e.g. prefer Requires: python2-django over
python-django).

@lsedlar would you like to review this? Addresses problems found by taskotron against kobo-0.7.0-1.fc26.

Looks good to me.

I didn't realize kobo-admin installs an executable. Maybe that package should not be renamed with the pythonX- prefix? Imagine a scenario where someone wants to use the command, so they run dnf install kobo-admin. It installs the python 2 version, but that does not provide the command because it's in the Python 3 subpackage. However I don't see a way to fix that without breaking possible users of the kobo.admin Python module. See this commit for an attempt at fixing that, but it does not really work. for all cases.

rebased onto b07dcbd

6 years ago

@lsedlar I think that's a good idea & I've included it into this pull request.

About other packages which might depend on kobo-admin and directly use kobo.admin module: from reviewing the code under kobo.admin, it appears intended for use only by the kobo-admin command. It only contains code for copying templates and it can only use kobo.admin as the source of the templates. So I feel comfortable assuming that there's few or no users who'll be affected by that change.

If there are probably no users of the API (which looks likely), then I think this should be good. :thumbsup: from me.

Pull-Request has been merged by rohanpm

6 years ago
Metadata