Bug 1449882 - Review Request: python-lcms2 - Simplified Python binding to LittleCMS2 library
Summary: Review Request: python-lcms2 - Simplified Python binding to LittleCMS2 library
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Athos Ribeiro
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-11 05:27 UTC by Luya Tshimbalanga
Modified: 2017-07-20 17:33 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-20 17:33:41 UTC
Type: ---
Embargoed:
athoscribeiro: fedora-review+


Attachments (Terms of Use)

Description Luya Tshimbalanga 2017-05-11 05:27:12 UTC
Spec URL: https://luya.fedorapeople.org/packages/SPECS/python-lcms2.spec
SRPM URL: https://luya.fedorapeople.org/packages/SRPMS/python-lcms2-0.1-1.fc25.src.rpm
Description: Simplified Python binding to LittleCMS2 library. 
This extension was created specially for SwatchBooker project. 
Nevertheless it can be used as a standalone package.
Fedora Account System Username:luya

Comment 1 Luya Tshimbalanga 2017-05-11 05:28:26 UTC
Scratch build:
https://koji.fedoraproject.org/koji/taskinfo?taskID=19493372

rpmlint result:
$ rpmlint ~/rpmbuild/RPMS/x86_64/python-lcms2-0.1-1.fc25.x86_64.rpm 
1 packages and 0 specfiles checked; 0 errors, 0 warnings.

Comment 2 Athos Ribeiro 2017-05-11 20:34:32 UTC
You might want to have a python 2 subpackage (even if upstream still does not support python 3) and use the python_provide macro [1]. This will probably save someone (probably you) some time in the future, when python 3 becomes the default or when upstream starts supporting python 3 as well.

Upstream provides a test suite, is there any reason for not running it in %check?

Defining sum is not needed. You could use the %{summary} macro instead if the summary was needed somewhere else.

[1] https://fedoraproject.org/wiki/Packaging:Python#The_.25python_provide_macro

Comment 3 Charalampos Stratakis 2017-05-11 21:13:20 UTC
Also it would be good to use the %py2_build and %py2_install macros instead of %py_build and %py_install (see [0]) as in the future, when python3 will be the default python, these macros will be changed to reflect that.


[0] https://fedoraproject.org/wiki/Packaging:Python#Example_common_spec_file

Comment 4 Luya Tshimbalanga 2017-05-11 22:51:29 UTC
(In reply to Athos Ribeiro from comment #2)
> You might want to have a python 2 subpackage (even if upstream still does
> not support python 3) and use the python_provide macro [1]. This will
> probably save someone (probably you) some time in the future, when python 3
> becomes the default or when upstream starts supporting python 3 as well.
Done.

> Upstream provides a test suite, is there any reason for not running it in
> %check?
Any suggestion how to properly write %check? Writing the line
"%{_python2} setup.py tests/lcms2_testsuite.py" or 
"%{_python2} tests/lcms2_testsuite.py" failed as a result

==================================== ERRORS ====================================
__________________ ERROR collecting tests/lcms2_testsuite.py ___________________
tests/lcms2_testsuite.py:18: in <module>
    import lcms2
E   ImportError: No module named lcms2
=========================== 1 error in 0.04 seconds ============================

 
> Defining sum is not needed. You could use the %{summary} macro instead if
> the summary was needed somewhere else.
> 
Fixed.

(In reply to Charalampos Stratakis from comment #3)
> Also it would be good to use the %py2_build and %py2_install macros instead
> of %py_build and %py_install (see [0]) as in the future, when python3 will
> be the default python, these macros will be changed to reflect that.
> 
Fixed.

Here is the updated specs
Spec URL: https://luya.fedorapeople.org/packages/SPECS/python-lcms2.spec
SRPM URL: https://luya.fedorapeople.org/packages/SRPMS/python-lcms2-0.1-2.fc25.src.rpm

Comment 5 Ken Dreyer 2017-05-12 02:53:32 UTC
(In reply to Luya Tshimbalanga from comment #4)
> Any suggestion how to properly write %check? Writing the line
> "%{_python2} setup.py tests/lcms2_testsuite.py" or 
> "%{_python2} tests/lcms2_testsuite.py" failed as a result

Try "export PYTHONPATH=$(pwd)" as the first line under %check.

Comment 6 Luya Tshimbalanga 2017-05-12 05:51:42 UTC
(In reply to Ken Dreyer from comment #5)
> (In reply to Luya Tshimbalanga from comment #4)
> > Any suggestion how to properly write %check? Writing the line
> > "%{_python2} setup.py tests/lcms2_testsuite.py" or 
> > "%{_python2} tests/lcms2_testsuite.py" failed as a result
> 
> Try "export PYTHONPATH=$(pwd)" as the first line under %check.

Unfortunately, the result is he same

+ export PYTHONPATH=/home/luya/rpmbuild/BUILD/python-lcms2-0.1
+ PYTHONPATH=/home/luya/rpmbuild/BUILD/python-lcms2-0.1
+ py.test-2 tests/lcms2_testsuite.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-2.9.2, py-1.4.33, pluggy-0.3.1
rootdir: /home/luya/rpmbuild/BUILD/python-lcms2-0.1, inifile: 
collected 0 items / 1 errors 

==================================== ERRORS ====================================
__________________ ERROR collecting tests/lcms2_testsuite.py ___________________
tests/lcms2_testsuite.py:18: in <module>
    import lcms2
E   ImportError: No module named lcms2
=========================== 1 error in 0.03 seconds ============================
error: Bad exit status from /var/tmp/rpm-tmp.QmXg4Y (%check)

Not sure what it will take for python to properly import lcms2

Comment 7 Charalampos Stratakis 2017-05-12 12:44:53 UTC
(In reply to Luya Tshimbalanga from comment #6)
> (In reply to Ken Dreyer from comment #5)
> > (In reply to Luya Tshimbalanga from comment #4)
> > > Any suggestion how to properly write %check? Writing the line
> > > "%{_python2} setup.py tests/lcms2_testsuite.py" or 
> > > "%{_python2} tests/lcms2_testsuite.py" failed as a result
> > 
> > Try "export PYTHONPATH=$(pwd)" as the first line under %check.
> 
> Unfortunately, the result is he same
> 
> + export PYTHONPATH=/home/luya/rpmbuild/BUILD/python-lcms2-0.1
> + PYTHONPATH=/home/luya/rpmbuild/BUILD/python-lcms2-0.1
> + py.test-2 tests/lcms2_testsuite.py
> ============================= test session starts
> ==============================
> platform linux2 -- Python 2.7.13, pytest-2.9.2, py-1.4.33, pluggy-0.3.1
> rootdir: /home/luya/rpmbuild/BUILD/python-lcms2-0.1, inifile: 
> collected 0 items / 1 errors 
> 
> ==================================== ERRORS
> ====================================
> __________________ ERROR collecting tests/lcms2_testsuite.py
> ___________________
> tests/lcms2_testsuite.py:18: in <module>
>     import lcms2
> E   ImportError: No module named lcms2
> =========================== 1 error in 0.03 seconds
> ============================
> error: Bad exit status from /var/tmp/rpm-tmp.QmXg4Y (%check)
> 
> Not sure what it will take for python to properly import lcms2

In order to debug this you can add the %clean macro with no arguments after the %install section as it will preserve all the files in the buildroot. Then you can build it with mock, shell inside the chroot and check the structure of the buildroot to figure out where the module is being placed.

Now this module imports itself after it has been compiled, to run the tests. However PYTHONPATH doesn't include the directories where the module is being placed inside the buildroot, so in these cases usually you will need to export the paths inside the buildroot (and the path structure mirrors the filesystem).

The location of _lcms2.so which should be imported, when looking inside the mock chroot is at:
/builddir/build/BUILDROOT/python-lcms2-0.1-2.fc27.x86_64/usr/lib64/python2.7/site-packages/lcms2

So in this case right after %check you will need to add. 
export PYTHONPATH=%{buildroot}%{python2_sitearch}

Comment 8 Luya Tshimbalanga 2017-05-12 19:00:40 UTC
(In reply to Charalampos Stratakis from comment #7)
> The location of _lcms2.so which should be imported, when looking inside the
> mock chroot is at:
> /builddir/build/BUILDROOT/python-lcms2-0.1-2.fc27.x86_64/usr/lib64/python2.7/
> site-packages/lcms2
> 
> So in this case right after %check you will need to add. 
> export PYTHONPATH=%{buildroot}%{python2_sitearch}

Thanks you for the details. That was the missing piece of puzzle needed to successfully build the package. Here is the updated specs:

Here is the updated specs
Spec URL: https://luya.fedorapeople.org/packages/SPECS/python-lcms2.spec
SRPM URL: https://luya.fedorapeople.org/packages/SRPMS/python-lcms2-0.1-3.fc25.src.rpm

Scratch build result:
https://koji.fedoraproject.org/koji/taskinfo?taskID=19511736

Valid local rpmlint result:
$ rpmlint rpmbuild/RPMS/x86_64/python2-lcms2-0.1-3.fc25.x86_64.rpm 
1 packages and 0 specfiles checked; 0 errors, 0 warnings.

rpmlint result from scratch build:
$ rpmlint python2-lcms2-0.1-3.fc27.x86_64.rpm 
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
1 packages and 0 specfiles checked; 0 errors, 2 warnings.


The warning message is a bug from rpmlint itself:
https://bugzilla.redhat.com/show_bug.cgi?id=1431408

Comment 9 Athos Ribeiro 2017-05-14 15:42:00 UTC
Hi Luya,

The package builds correctly now, thanks for the modification.

- Upstream ships the full GPLv3 licence text in the GPLv3.txt file, it would be nice to ship it as well. The content in the LICENSE file is just the GPL copying permission statement.

- You should now remove the %clean section from the spec file [1].

- rpmlint complains about mixed usage of spaces and tabs in the spec file (lines 12 and 14 use tabs and the rest of the spec file uses spaces).

- There are .icm files in testdata dir. One of them is tagged as Public Domain and the other one is under a HP copyright, are they both also licensed as GPLv3 [2]? Do you have any comments on those?

[1] https://fedoraproject.org/wiki/Packaging:Guidelines#Tags_and_Sections
[2] https://fedoraproject.org/wiki/Packaging:Guidelines#Code_Vs_Content

Package Review
==============

Legend:
[x] = Pass, [!] = Fail, [-] = Not applicable, [?] = Not evaluated

===== MUST items =====

C/C++:
[x]: Package does not contain kernel modules.
[x]: Package contains no static executables.
[x]: Development (unversioned) .so files in -devel subpackage, if present.
     Note: Unversioned so-files in private %_libdir subdirectory (see
     attachment). Verify they are not in ld path.
[x]: Package does not contain any libtool archives (.la)
[x]: Rpath absent or only used for internal libs.

Generic:
[x]: Package is licensed with an open-source compatible license and meets
     other legal requirements as defined in the legal section of Packaging
     Guidelines.
[!]: License field in the package spec file matches the actual license.
[x]: License file installed when any subpackage combination is installed.
[x]: %build honors applicable compiler flags or justifies otherwise.
[x]: Package contains no bundled libraries without FPC exception.
[x]: Changelog in prescribed format.
[!]: Sources contain only permissible code or content.
[-]: Package contains desktop file if it is a GUI application.
[-]: Development files must be in a -devel package
[x]: Package uses nothing in %doc for runtime.
[x]: Package consistently uses macros (instead of hard-coded directory
     names).
[x]: Package is named according to the Package Naming Guidelines.
[x]: Package does not generate any conflict.
[x]: Package obeys FHS, except libexecdir and /usr/target.
[x]: If the package is a rename of another package, proper Obsoletes and
     Provides are present.
[x]: Requires correct, justified where necessary.
[x]: Spec file is legible and written in American English.
[-]: Package contains systemd file(s) if in need.
[x]: Useful -debuginfo package or justification otherwise.
[x]: Package is not known to require an ExcludeArch tag.
[-]: Large documentation must go in a -doc subpackage. Large could be size
     (~1MB) or number of files.
[!]: Package complies to the Packaging Guidelines
[x]: Package successfully compiles and builds into binary rpms on at least
     one supported primary architecture.
[x]: Package installs properly.
[x]: Rpmlint is run on all rpms the build produces.
     Note: There are rpmlint messages (see attachment).
[x]: If (and only if) the source package includes the text of the
     license(s) in its own file, then that file, containing the text of the
     license(s) for the package is included in %license.
[x]: Package requires other packages for directories it uses.
[x]: Package must own all directories that it creates.
[x]: Package does not own files or directories owned by other packages.
[x]: All build dependencies are listed in BuildRequires, except for any
     that are listed in the exceptions section of Packaging Guidelines.
[x]: Package uses either %{buildroot} or $RPM_BUILD_ROOT
[x]: Package does not run rm -rf %{buildroot} (or $RPM_BUILD_ROOT) at the
     beginning of %install.
[x]: Macros in Summary, %description expandable at SRPM build time.
[x]: Dist tag is present.
[x]: Package does not contain duplicates in %files.
[x]: Permissions on files are set properly.
[x]: Package use %makeinstall only when make install DESTDIR=... doesn't
     work.
[x]: Package is named using only allowed ASCII characters.
[x]: Package does not use a name that already exists.
[x]: Package is not relocatable.
[x]: Sources used to build the package match the upstream source, as
     provided in the spec URL.
[x]: Spec file name must match the spec package %{name}, in the format
     %{name}.spec.
[x]: File names are valid UTF-8.
[x]: Packages must not store files under /srv, /opt or /usr/local

Python:
[x]: Python eggs must not download any dependencies during the build
     process.
[x]: A package which is used by another package via an egg interface should
     provide egg info.
[x]: Package meets the Packaging Guidelines::Python
[x]: Package contains BR: python2-devel or python3-devel
[x]: Binary eggs must be removed in %prep

===== SHOULD items =====

Generic:
[-]: If the source package does not include license text(s) as a separate
     file from upstream, the packager SHOULD query upstream to include it.
[x]: Final provides and requires are sane (see attachments).
[x]: Fully versioned dependency in subpackages if applicable.
[?]: Package functions as described.
[x]: Latest version is packaged.
[x]: Package does not include license text files separate from upstream.
[-]: Description and summary sections in the package spec file contains
     translations for supported Non-English languages, if available.
[?]: Package should compile and build into binary rpms on all supported
     architectures.
[x]: %check is present and all tests pass.
[x]: Packages should try to preserve timestamps of original installed
     files.
[x]: Reviewer should test that the package builds in mock.
[x]: Buildroot is not present
[x]: Package has no %clean section with rm -rf %{buildroot} (or
     $RPM_BUILD_ROOT)
[x]: No file requires outside of /etc, /bin, /sbin, /usr/bin, /usr/sbin.
[x]: Packager, Vendor, PreReq, Copyright tags should not be in spec file
[x]: Sources can be downloaded from URI in Source: tag
[x]: SourceX is a working URL.
[x]: Spec use %global instead of %define unless justified.

===== EXTRA items =====

Generic:
[x]: Rpmlint is run on debuginfo package(s).
     Note: No rpmlint messages.
[x]: Rpmlint is run on all installed packages.
     Note: There are rpmlint messages (see attachment).
[x]: Large data in /usr/share should live in a noarch subpackage if package
     is arched.
[x]: Spec file according to URL is the same as in SRPM.


Rpmlint
-------
Checking: python2-lcms2-0.1-3.fc27.x86_64.rpm
          python-lcms2-debuginfo-0.1-3.fc27.x86_64.rpm
          python-lcms2-0.1-3.fc27.src.rpm
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
python-lcms2.src:12: W: mixed-use-of-spaces-and-tabs (spaces: line 3, tab: line 12)
3 packages and 0 specfiles checked; 0 errors, 3 warnings.

Rpmlint (debuginfo)
-------------------
Checking: python-lcms2-debuginfo-0.1-3.fc27.x86_64.rpm
1 packages and 0 specfiles checked; 0 errors, 0 warnings.

Rpmlint (installed packages)
----------------------------
sh: /usr/bin/python: No such file or directory
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
python2-lcms2.x86_64: W: hidden-file-or-dir /usr/lib/.build-id
2 packages and 0 specfiles checked; 0 errors, 2 warnings.

Requires
--------
python2-lcms2 (rpmlib, GLIBC filtered):
    libc.so.6()(64bit)
    liblcms2.so.2()(64bit)
    libpthread.so.0()(64bit)
    libpython2.7.so.1.0()(64bit)
    python(abi)
    rtld(GNU_HASH)

python-lcms2-debuginfo (rpmlib, GLIBC filtered):


Provides
--------
python2-lcms2:
    python-lcms2
    python-lcms2(x86-64)
    python2-lcms2
    python2-lcms2(x86-64)
    python2.7dist(lcms2)
    python2dist(lcms2)

python-lcms2-debuginfo:
    python-lcms2-debuginfo
    python-lcms2-debuginfo(x86-64)


Source checksums
----------------
https://github.com/sk1project/python-lcms2/archive/v0.1.tar.gz#/python-lcms2-0.1.tar.gz :
  CHECKSUM(SHA256) this package     : 74921a6e7ccc54f5efa5c3277675e09ae71fcfd86b3a3cd2e8d11171e7ab83a5
  CHECKSUM(SHA256) upstream package : 74921a6e7ccc54f5efa5c3277675e09ae71fcfd86b3a3cd2e8d11171e7ab83a5

Comment 10 Luya Tshimbalanga 2017-05-14 18:56:52 UTC
(In reply to Athos Ribeiro from comment #9)
> Hi Luya,
> 
> The package builds correctly now, thanks for the modification.
> 
> - Upstream ships the full GPLv3 licence text in the GPLv3.txt file, it would
> be nice to ship it as well. The content in the LICENSE file is just the GPL
> copying permission statement.

Fixed.
 
> - You should now remove the %clean section from the spec file [1].

Done 
> - rpmlint complains about mixed usage of spaces and tabs in the spec file
> (lines 12 and 14 use tabs and the rest of the spec file uses spaces).

Fixed

> - There are .icm files in testdata dir. One of them is tagged as Public
> Domain and the other one is under a HP copyright, are they both also
> licensed as GPLv3 [2]? Do you have any comments on those?

Public Domain should be ok as permitted license. Only that old version of sRGB is not permitted according to the License guideline (https://fedoraproject.org/wiki/Licensing:Main#Bad_Licenses). I filed a upstream report to request a change replacing that icm with a FSF compatible which is already available on http://www.color.org/srgbprofiles.xalter. See https://github.com/sk1project/python-lcms2/issues/1

Considering that section containing that old version of SRGB is only intended for testing within %check, is there an alternative approach to replace it with the one from colord?
 
Updated specs:

Here is the updated specs
Spec URL: https://luya.fedorapeople.org/packages/SPECS/python-lcms2.spec
SRPM URL: https://luya.fedorapeople.org/packages/SRPMS/python-lcms2-0.1-4.fc25.src.rpm

Comment 11 Athos Ribeiro 2017-05-14 22:58:04 UTC
Thanks for the changes!


> Considering that section containing that old version of SRGB is only
> intended for testing within %check, is there an alternative approach to
> replace it with the one from colord?

I see 3 alternatives here:

1) Remove the bad file from the sources and do not run tests that use the file in %check.

2) Remove the bad file from the sources, add the one with the good license and run the tests with it (it would be nice to send such patch upstream)

3) wait an upstream action before going on with this review.

Now, It's up to you to pick one of those or propose some other solution. If you are going with 1 or 2, remember that you need to remove the bad file from the tarball, before even generating a srpm. Here are 2 nice examples of how you can accomplish that: [1], [2].

[1] https://fedoraproject.org/wiki/Packaging:SourceURL#When_Upstream_uses_Prohibited_Code

[2] http://pkgs.fedoraproject.org/cgit/rpms/calibre.git/tree/getsources.sh

Comment 12 Luya Tshimbalanga 2017-05-15 04:46:42 UTC
Thank you for the suggestion. Option #2 suits the need by using the public domain sRGB which runs the test.


Here is the updated specs with removed bad licensed file
Spec URL: https://luya.fedorapeople.org/packages/SPECS/python-lcms2.spec
SRPM URL: https://luya.fedorapeople.org/packages/SRPMS/python-lcms2-0.1-4.fc25.src.rpm

Comment 13 Athos Ribeiro 2017-05-15 11:44:48 UTC
Package looks good now!

There are still a few rpmlint warnings for the spec file, but I will trust you will fix the following ones before uploading the package:

python-lcms2.src:10: W: macro-in-comment %{name}
python-lcms2.src:10: W: macro-in-comment %{version}
python-lcms2.src:10: W: macro-in-comment %{name}
python-lcms2.src:10: W: macro-in-comment %{version}
python-lcms2.src:31: W: mixed-use-of-spaces-and-tabs (spaces: line 31, tab: line 3)

- For the macros, just add an extra % before the first %.

- For the tabs you can run something like
sed -i 's/\t/  /g' python-lcms2.spec

The other warnings are false positives, so you should not worry about them.

Package approved.

Comment 14 Luya Tshimbalanga 2017-05-15 17:09:46 UTC
Thank you for the detailed review and suggestion, Athos!

Comment 15 Gwyn Ciesla 2017-05-15 17:17:11 UTC
Package request has been approved: https://admin.fedoraproject.org/pkgdb/package/rpms/python-lcm2

Comment 16 Gwyn Ciesla 2017-05-16 17:05:16 UTC
Package request has been approved: https://admin.fedoraproject.org/pkgdb/package/rpms/python-lcms2

Comment 17 Athos Ribeiro 2017-07-19 22:55:54 UTC
Shall we close this?

Comment 18 Luya Tshimbalanga 2017-07-20 17:04:08 UTC
Please go ahead. Python-lcms2 is packaged.


Note You need to log in before you can comment on or make changes to this bug.