2

I'm unable to use py2app to build a python application which contains the pillow package. I'm using:

  • Mac OSX El Capitan (10.11.16)
  • Python 3.7.3 (Installed via Homebrew)
  • Pillow 6.0.0
  • py2app 0.19
  • macholib 1.11

The script works fine when called from the command line and the py2app bundle works fine if compiled in alias mode python3 setup.py py2app -A

But, when I try to compile a standalone bundle using: python3 setup.py py2app --packages=PIL

I get the following error message:

ValueError: New Mach-O header is too large to relocate in '/Users/RG/Library/Mobile Documents/com~apple~CloudDocs/iHal/Code/QuotesApp/dist/Quotes.app/Contents/Resources/lib/python3.7/PIL/.dylibs/liblcms2.2.dylib' (new size=1688, max size=1680, delta=48)

I've been searching but have had no luck finding help with this issue, is it possible it's an El Capitan (OSX 10.11.16) issue?

jmrq
  • 63
  • 7

1 Answers1

5

my system specs:

  • Mac OSX Mojave (10.14.15)
  • Python 3.7.4 (python.org)
  • Pillow 6.1.0
  • py2app 0.19
  • macholib 1.11

I had the same issues as you. The reason why it fails is that the library is wrong compiled. I figured out two solutions. On my system the library is located at: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PIL/.dylibs/

If you do not use color management in your project you can delete the library "liblcms2.2.dylib". Now you can run py2app and it will build.

The second solution is more work and the way I use it in my project. First, you need Xcode because we have to recompile the "littlecms" library.

Xcode is around 6gb and you get it from the Apple Appstore. On my system have the version 10.2.1.

Download the library littlecms in version 2.2: https://www.littlecms.com/ You will be redirected to SourceForge: https://sourceforge.net/projects/lcms/files/lcms/2.2/

Download one of these files: lcms2-2.2.zip or lcms2-2.2.tar.gz and extract it on your system. The library source comes with the Xcode project file and you will find in Projects/mac. If you are familiar with the terminal you can build it without the Xcode GUI. In this case, go into the extracted folder of littlecms and type following commands.

  • ./configure
  • make
  • make check

If the last command(make check) runs fine the library is ready for deployment. You will find the compiled library in the folder: src/.libs/. Replace the library which comes with the PIL package with your compiled library. Finally, run py2app to build your project.

If this is not working you have to tell the linker a flag. Go to your littlecms source folder and type the commands:

  • make clean
  • ./configure LDFLAGS="-headerpad_max_install_names"
  • make
  • make check

Replace the compiled library with the PIL.

so long,

Phil

Ratan Uday Kumar
  • 5,738
  • 6
  • 35
  • 54
EgOPhil
  • 81
  • 7
  • 1
    Phil, thanks for posting your solution. I'll try to take a look at your suggestions this weekend and report back soon. Thanks! – jmrq Jul 18 '19 at 11:45