Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag packages that depend on Pillow for special installation steps #64

Open
jbarlow83 opened this issue Jul 11, 2018 · 2 comments
Open

Comments

@jbarlow83
Copy link

Homebrew requires a special installation procedure to ensure that the correction combination of dependencies from Apple system libraries and Homebrew libraries are selected. Pillow is also a popular and widely used library so this special case is likely to occur often enough in practice.

It would be helpful if poet advised users that Pillow needs special procedures and that one should search for a recently updated formula in homebrew-core and copy that.

Provided no other packages need special steps, it could also reproduce the boilerplate to install Pillow, which is as follows:

  depends_on "freetype"
  depends_on "jpeg"

  [...] snip

  def install
    venv = virtualenv_create(libexec, "python3")

    resource("Pillow").stage do
      inreplace "setup.py" do |s|
        sdkprefix = MacOS::CLT.installed? ? "" : MacOS.sdk_path
        s.gsub! "openjpeg.h", "probably_not_a_header_called_this_eh.h"
        s.gsub! "ZLIB_ROOT = None", "ZLIB_ROOT = ('#{sdkprefix}/usr/lib', '#{sdkprefix}/usr/include')"
        s.gsub! "JPEG_ROOT = None", "JPEG_ROOT = ('#{Formula["jpeg"].opt_prefix}/lib', '#{Formula["jpeg"].opt_prefix}/include')"
        s.gsub! "FREETYPE_ROOT = None", "FREETYPE_ROOT = ('#{Formula["freetype"].opt_prefix}/lib', '#{Formula["freetype"].opt_prefix}/include')"
      end

      # avoid triggering "helpful" distutils code that doesn't recognize Xcode 7 .tbd stubs
      ENV.append "CFLAGS", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" unless MacOS::CLT.installed?
      venv.pip_install Pathname.pwd
    end

    res = resources.map(&:name).to_set - ["Pillow"]

    res.each do |r|
      venv.pip_install resource(r)
    end
  end
@jbarlow83 jbarlow83 changed the title Flag packages that depend Pillow for special installation Flag packages that depend on Pillow for special installation steps Jul 11, 2018
@tdsmith
Copy link
Owner

tdsmith commented Jul 11, 2018

What happens if you don't do anything special for Pillow?

@jbarlow83
Copy link
Author

Good question. Without the patch, Pillow's setup.py will use pkg-config to attempt to locate the libraries and it needs, and will link differently depending on what the user has installed, so it may or may not work. Also, as the "avoid triggering" comment implies, it works around a bug affecting distutils and Xcode 7.

That being said, I didn't develop this, I just know about it because the homebrew-core team added it to my formula. @fxcoudert may be able to add further detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants