Skip to content

JPEG not detected when installing Pillow under Cygwin64 #6216

Closed

Description

@biogberg

Hello,

Attempting to install the current version of Pillow (9.1.0) fails with Python-3.9.10 under Cygwin64. I attempted installing both via pip3 and via python3 setup.py build. Both fail the same way.

Installation succeeds until the configuration stops with a message that the required headers and/or library files for jpeg were not found.

Jpeg packages (both jpeg and openjpeg) are installed including the developer packages. Both header files and library files are in fact present in the right directories.

I had a hunch that this might be a library file naming issue. In /usr/lib the following jpeg-related files are present:
/usr/lib/libjpeg.dll.a
/usr/lib/libopenjpeg.dll.a

To test, I built and installed a static libjpeg.a and put libjpeg.a file in /usr/local/lib. That done, the build succeeded to the point that the extension was built. However, most other supporting libraries were not detected despite that most of them were in fact installed (including developer packages); the corresponding packages all exclusively install shared libraries (dll's), not static:

The output from the build produced:

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version      Pillow 9.1.0
platform     cygwin 3.9.10 (main, Jan 20 2022, 21:37:52)
             [GCC 11.2.0]
--------------------------------------------------------------------
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBIMAGEQUANT support not available
*** LIBTIFF support not available
*** FREETYPE2 support not available
*** RAQM (Text shaping) support not available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
*** XCB (X protocol) support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library and headers.

There is in fact a zlib static library in /usr/lib and, thus, presence of zlib was detected.

So either:

  1. the build currently only works with static libraries, or
  2. there is a an issue with properly detecting the shared libraries.

Under Cygwin the dll files are located in /usr/bin with names such as cygtiff-6.dll, cygjpeg-8.dll, cygopenjpeg-1.dll, cygimagequant-0.dll etc. The link files have names such as libjpeg.dll.a etc.

  • OS: Cygwin64 under Windows 10 (64 bit) updated
  • Python: 3.9.10 (Cygwin64 version updated)
  • Pillow: 9.1.0

Activity

  1. changed the title [-]Installation of Pillow fails under Cygwin64 due jpeg not being detected[/-] [+]JPEG not detected when installing Pillow under Cygwin64[/+] on Apr 16, 2022
  2. radarhere commented on Apr 23, 2022

    @radarhere
    Member

    @DWesl do you have any thoughts on this one?

  3. DWesl commented on Apr 23, 2022

    @DWesl
    Contributor

    I know the Pillow tests require jpeg command-line utilities in addition to the jpeg and jpeg-2000 libraries. From #5878, the relevant Cygwin packages seem to be jpeg libjpeg-devel libopenjp2-devel. I have not had problems with linking to dynamic libraries (with the .dll.a import libraries) rather than static libraries.

    If installing the packages mentioned before doesn't fix the issue, it would help to have a list of installed Cygwin packages, with cygcheck -c, or perhaps even the full (perhaps filtered to replace ${USER}, ${HOSTNAME}, ${COMPUTERNAME}, ${TZ} and similar) output of cygcheck -svr, that I could check.

  4. biogberg commented on Apr 24, 2022

    @biogberg
    Author

    Thank you for your responses!

    The list of installed packages is attached.

    cygwin_pkgs.txt.gz

  5. DWesl commented on Apr 28, 2022

    @DWesl
    Contributor

    You may want libopenjp2-devel, which seems kinda relevant from my list of installed packages. python39-sip is probably irrelevant for this, but is on my list of packages.

    Are you installing using setup-x86_64.exe?

  6. biogberg commented on Apr 29, 2022

    @biogberg
    Author

    Yes, everything is installed using setup-x86_64.exe.
    Installing python39-sip and libopenjp2-devel did not change anything the output is still:

      File "/home/pqb793/src/python/Pillow-9.1.0/setup.py", line 804, in build_extensions
        raise RequiredDependencyException(f)
    __main__.RequiredDependencyException: jpeg
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/pqb793/src/python/Pillow-9.1.0/setup.py", line 1009, in <module>
        raise RequiredDependencyException(msg)
    __main__.RequiredDependencyException:
    
    The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.
    
    Please see the install instructions at:
       https://pillow.readthedocs.io/en/latest/installation.html
    

    And: as mentioned above, adding a static libjpeg. a to /usr/local allows installation to (sort of) work.

  7. DWesl commented on Apr 29, 2022

    @DWesl
    Contributor

    Well that's weird. What's your PATH like? Does env PATH=/usr/bin:/bin /usr/bin/python3.9 setup.py build_ext get farther?

  8. DWesl commented on Apr 30, 2022

    @DWesl
    Contributor

    I can reproduce this on 32-bit Cygwin. This wasn't an issue a few months ago, so you should be able to get pillow from a version or three back. I haven't figured out where things are breaking yet.

  9. DWesl commented on May 1, 2022

    @DWesl
    Contributor

    Try installing setuptools<60, then running python setup.py build_ext

  10. biogberg commented on May 2, 2022

    @biogberg
    Author

    BINGO!
    Replacing pip3-installed setuptools 62.1.0 with pip3-installed 59.8.0 (the final pre-60 release) allows python setup.py build_ext to complete.
    The setup summary now becomes:

    --------------------------------------------------------------------
    PIL SETUP SUMMARY
    --------------------------------------------------------------------
    version      Pillow 9.1.0
    platform     cygwin 3.9.10 (main, Jan 20 2022, 21:37:52)
                 [GCC 11.2.0]
    --------------------------------------------------------------------
    --- JPEG support available
    --- OPENJPEG (JPEG2000) support available (2.4)
    --- ZLIB (PNG/ZIP) support available
    --- LIBIMAGEQUANT support available
    --- LIBTIFF support available
    --- FREETYPE2 support available
    --- RAQM (Text shaping) support available
    --- LITTLECMS2 support available
    --- WEBP support available
    --- WEBPMUX support available
    --- XCB (X protocol) support available
    --------------------------------------------------------------------
    

    Installation of Pillow worked under Cygwin64 worked some time ago. For Python 3.8, I have a dist-info directory with files with modification date Oct 24, 2021.

  11. DWesl commented on May 2, 2022

    @DWesl
    Contributor

    Cygwin setuptools is still at version 59.5.0, so install should work on a new Cygwin64 installation. Cygwin isn't likely to upgrade until NumPy and setuptools>60 regain compatibility

    Do you want to report this to setuptools, or should I?

  12. biogberg commented on May 2, 2022

    @biogberg
    Author

    It will probably have a greater impact if you do...

  13. radarhere commented on May 2, 2022

    @radarhere
    Member

    Thanks very much for figuring this one out.

    Closing. pypa/setuptools#3302 can now be followed instead.

  14. DWesl commented on May 10, 2022

    @DWesl
    Contributor

    pypa/distutils#139 has merged a fix into upstream of setuptools, so that fix should be propagating into setuptools in time.

    For anyone who needs a fix before then and cannot downgrade to setuptools<60, setting an environment variable SETUPTOOLS_USE_DISTUTILS=stdlib should allow the patches in the Cygwin python packages to handle this case, and I think that environment variable will stick around until setuptools upgrades its bundled distutils.

  15. biogberg commented on May 10, 2022

    @biogberg
    Author

    Thank you for helping with this!

  16. added a commit that references this issue on Dec 10, 2022
  17. added a commit that references this issue on Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions