How to Build MyPaint on Mac OSX (without MacPorts)

5 min read

Deviation Actions

Angelus-Tenebrae's avatar
Published:
4K Views
So, I found another FOSS graphical editing software like Krita, only it has a slightly different focus, like sketching and an infinite canvas. Unfortunately, like Krita, it's a pain in the ass to build. Thankfully, not as cumbersome as Krita, but it still took a lot of time, and pressure sensitivity still doesn't work. It's sufficient for blueprints, diagrams and other plans though. You can go the easy route and build it with MacPorts, but if you're on Homebrew like me and don't want to mess up your system by installing MacPorts, then read on. You will have to touch the console for this though, so if you really want it, just put up with it. It's not that bad. You can follow along the instructions in the readme on Github here: github.com/mypaint/mypaint/blo…
I will just make notes here for stuff you need to adjust since that guide is catered for MacPort users. Please note that I built this on Mavericks. I have no idea if the process will be different on Yosemite or El Capitan.

Setup environment variables

Just use the same export variables as in the guide. You will probably have to change the paths for them though.
PKG_CONFIG_PATH - where you will find .pc files for pkgconfig. If you hit on a folder with a ton of .pc files, then you've probably found it. In Homebrew, it's under
/usr/local/lib/pkgconfig
CFLAGS - include folder for most libraries used as dependencies. On non-Macports (and probably Homebrew), this is usually under
/usr/local/include

CC and CXX flags - SCons, the build tool will use whatever default value you have set for the CC and CXX flags. My computer didn't pick the right one, so if you get weird wrong architecture symbol errors, just set them:
export CC="clang -arch x86_64"
export CXX="clang++ -arch x86_64"

Install dependencies

I used Python 2.7 for this. You may not need the Homebrew version of this, but depending on how you have it set up, Homebrew prefers its version of Python. Which is okay, except that you will later have to tell SCons to use the Homebrew Python as well. Most of the dependencies below can be obtained through Homebrew. Sometimes, Homebrew will not link the dependencies because your system might have a version of it already. If you plan to use these dependencies for building MyPaint, you will have to link them. Use
brew link [dependency]
for that. If you've already built Krita, some of these dependencies might look familiar.

  • swig
  • scons
  • pkgconfig (you can install this from pip or Homebrew)
  • gettext (if you install this with Homebrew, make sure it's linked.)
  • gtk3 (in Homebrew, it's gtk+3)
  • pygobject3 (if you install this with Homebrew make sure it's linked. Note: this is not the same as python-gi. python-gi is only for pygobject2, and if you already have it, the gi module will not build properly with MyPaint. Make sure the one linked here is from pygobject3. You can find them in /usr/local/lib/python2.7/site-packages/gi.)
  • libffi (this will probably be installed with pygobject3, but if you installed it with Homebrew, make sure it's linked.)
  • json-c
  • hicolor-icon-theme (Should be installed with gtk3 if you're using Homebrew)
  • librsvg
  • libpng (OSX usually comes with this. If you don't already have it, you should get it now.)
  • lcms2 (in Homebrew, it's little-cms2)
If you're not building with Homebrew, you'll need these as well:
  • glib2
  • cairo
Some dependencies you should install with pip:
sudo pip install [dependency]
  • numpy
  • scipy
  • pyobjc-framework-Cocoa (you do not need the entire pyobjc framework! Save yourself the frustration and time by only getting this one.)

Clone source files

As per the readme.

Build
Note: If you build dependencies with Homebrew, you must tell SCons to use the Python binary from Homebrew: In SConstruct, there is a line like
opts.Add('python_binary', 'python executable to build for', $).
Replace $ with the actual path from the Homebrew binary:
'/usr/local/Cellar/python/[version]/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python'
Do the same for the python_config option below it as well, but link to
'/usr/local/Cellar/python/[version]/Frameworks/Python.framework/Versions/2.7/bin/python-config'
Then run SCons like in the instructions. I personally didn't have to use sudo -E, but your mileage may vary.

Running
The readme suggests running the app with a -c flag, but I'm not sure if you absolutely have to specify it every time you run MyPaint. To automate that process (since there are no app bundles yet), I wrote a little script that you can run instead:

#!/bin/sh
./mypaint -c /tmp/mypaint_cfgtmp_$$

Just save it as something like mypaint.sh and run it with
./mypaint.sh

from your MyPaint folder.

Troubleshooting


Mypaint can't find its icons

If you have attempted previous installs of other graphics software like Krita, you may have set up a XDG_DATA_DIRS environment variable. MyPaint attempts to find hicolor icons from this variable, and it might not get added automatically. You will have to add it yourself. If you installed hicolor-icon-theme with Homebrew, the icons are under
/usr/local/share/icons
(but linking /usr/local/share should be good enough).

MacPorts Differences
I actually looked at the portfile to see the missing dependencies that I needed that weren't in the readme. It appears that Homebrew tends to build the dependencies for the dependencies listed in the portfile, so I didn't mention cairo or glib except for building from source. Also, I did a clean install from a different computer without protobuf, and found it wasn't required. Either that, or I already had protobuf and just didn't notice it. If you need it though, you can get it through pip. I've never actually tried the MacPorts build, so I don't know if it just builds it from source and bundles an actual OSX app, or if it just dumps the build files somewhere and links them to what looks like an app, like the Homebrew cask version of MyPaint does (which is actually outdated, and the whole reason I wrote this guide). Bundling could be an interesting exercise though.
© 2016 - 2022 Angelus-Tenebrae
Comments0
Join the community to add your comment. Already a deviant? Log In