googlefonts / fontdiffenator

Font comparison tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

macOS install requires cairo and pkg-config dependencies from pycairo

chrissimpkins opened this issue · comments

Also filed on gftools googlefonts/gftools#106

System:

  • macOS 10.14.2
  • XCode 10.1
  • Python 3.7.2

What I did:

Attempted a new install of gftools master branch at googlefonts/gftools@8ffa69c by cloning the repository and installing with:

pip install -e .

What happened:

Installing collected packages: Werkzeug, itsdangerous, Flask, absl-py, glyphsLib, tabulate, pycairo, uharfbuzz, freetype-py, fontdiffenator, nose, olefile, simplejson, pybrowserstack-screenshots, gfdiffbrowsers, gftools
  Running setup.py install for pycairo ... error
    Complete output from command /usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/x7/vs8mbwmx1hg1vcb53nlygt0m0000gn/T/pip-install-yjt3s04w/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/x7/vs8mbwmx1hg1vcb53nlygt0m0000gn/T/pip-record-dbpg93da/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/cairo
    copying cairo/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/cairo
    copying cairo/__init__.pyi -> build/lib.macosx-10.14-x86_64-3.7/cairo
    copying cairo/py.typed -> build/lib.macosx-10.14-x86_64-3.7/cairo
    running build_ext
    'pkg-config' not found.
    Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']

    ----------------------------------------
Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/x7/vs8mbwmx1hg1vcb53nlygt0m0000gn/T/pip-install-yjt3s04w/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/x7/vs8mbwmx1hg1vcb53nlygt0m0000gn/T/pip-record-dbpg93da/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/x7/vs8mbwmx1hg1vcb53nlygt0m0000gn/T/pip-install-yjt3s04w/pycairo/

How I Fixed It:

The fontdiffenator dependency PyCairo requires a homebrew install of cairo and pkg-config. I've apparently previously installed cairo, but not pkg-config.

$ brew install pkg-config
$ pip install -e .

and gftools installed without problems. Happy to file a README update PR with these instructions if I am not missing something. I checked and pkg-config does not appear to be installed with XCode CL tools. Seems to require a manual install before the pip install attempt here.

I ran into this problem again with an attempt to update fontdiffenator with Py 3.7.4/pip3 via PyPI. I resolved it with the following:

$ brew uninstall --ignore-dependencies cairo
$ brew install --cc=clang cairo

The compiler definition seems to be important on macOS installs.

Thanks @chrissimpkins
I had the same issue and with this is solved