Skip to content

Instantly share code, notes, and snippets.

@jenskutilek
Created April 21, 2022 16:15
Show Gist options
  • Save jenskutilek/2e60b3c4b684576691edfe137a658537 to your computer and use it in GitHub Desktop.
Save jenskutilek/2e60b3c4b684576691edfe137a658537 to your computer and use it in GitHub Desktop.
Migrating a font development environment to Apple Silicon

Installing a font development environment on Apple Silicon

I have a new Apple Silicon Mac and have migrated everything from my old Mac running macOS 10.13. That means that many Python and other command line tools are already installed, but may have been compiled for the wrong CPU type.

Python

I’m pretty sure that just installing the latest Python version will save us some trouble. Download and install Python 3.10.4 from https://www.python.org/downloads/release/python-3104/

Our system-wide Python packages (some of them include compiled libraries), e.g. powerline-status, have not been updated yet, so terminal apps won’t launch properly. Opening our ~.zshrc file and commenting out all lines that concern powerline, rbenv, and nvm/node makes Terminal.app and iTerm launch at least. But Python won’t run at all yet:

$ /usr/bin/python3
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Ah yes, most Python stuff has been removed by Apple in macOS 12.3.1, so the Apple command line developer tools must be installed:

$ xcode-select --install

Still, pip wouldn’t run. Apple has removed the /usr/bin/python executable as well, now many Python scripts, including pip, point to a non-existing interpreter.

Open /usr/local/bin/pip in a text editor and edit the first line to point to the Python we just installed:

#!/usr/local/bin/python3.10

Trying to build a variable font project from FontLab 5 sources, I get blocked again:

/usr/local/bin/vfb2ufo: Bad CPU type in executable

OK, let’s save this for later.

But we have a working Python 3.10 now, so let’s try a build directly from UFO sources with fontmake. We are in a virtual environment now, otherwise I would include the --user flag to install everything in ~/Library/Python/....

The xattr module needs reinstallation for the new CPU type:

$ pip install -U --force xattr

And lxml also has the wrong architecture:

$ pip install -U --force lxml

But that gives us the x64-only version again. Try to disable the wheel:

$ pip install -U --force lxml --no-binary :all:

Success.

More modules in need of reinstallation come up:

$ pip install -U --force brotli opentype-sanitizer uharfbuzz numpy skia-pathops

At this point I give up and rebuild the virtual environment from scratch. Caveat: When you just type virtualenv, the command will be found in /usr/local/bin and fail. I didn’t instantly find out why /usr/local/bin takes precedence over my user Python path, so we just pass the full path to the command:

$ /Users/jens/Library/Python/3.10/bin/virtualenv env3.10a

After reinstalling all packages from scratch, lxml is installed for the wrong architecture again. We need to install it without the wheel one more time:

$ pip install -U --force lxml --no-binary :all:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment