Relevant KLayout version: 0.30.2
Author: Kazzz-S
Last modified: 2025-05-30
# 1. Introduction
This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.30.2 or later for different 64-bit macOS, including:
* Sequoia (15.x) : the primary development environment
* Sonoma (14.x) : experimental
* Ventura (13.x) : -- ditto --
Building KLayout for the previous operating systems listed below has been discontinued.
Pre-built DMG packages are also not provided.
* Monterey (12.7.6; the build is still possible, but Homebrew stopped supporting this OS in September 2024)
* Big Sur (11.7.10)
* Catalina (10.15.7)
* Mojave (10.14)
* High Sierra (10.13)
* Sierra (10.12)
* El Capitan (10.11)
Throughout this document, the primary target machine is **Intel x86_64** with **macOS Sequoia**.
All Apple (M1|M2|M3|M4) chips are still untested, as the author does not own an (M1|M2|M3|M4) Mac.
However, some kind volunteers told me they successfully built on an Apple silicon machine.
# 2. Qt Frameworks
The default Qt framework is "Qt5" from **MacPorts** (https://www.macports.org/), which is usually located under:
```
/opt/local/libexec/qt5/
```
If you prefer "Qt6" from **Homebrew** (https://brew.sh/), which is usually located under:
```
/usr/local/opt/qt@6/
```
You can also choose "Qt5" from Anaconda3 (https://www.anaconda.com/), which is usually located under:
```
$HOME/opt/anaconda3/pkgs/qt-{version}
```
If you have installed Anaconda3 under $HOME/opt/anaconda3/, make a symbolic link:
```
/Applications/anaconda3/ ---> $HOME/opt/anaconda3/
```
The migration work to "Qt6" is ongoing. You can try to use it; however, you might encounter some build or runtime errors.
If you use **Homebrew** to build KLayout >= 0.29.0, you need "Qt6" to address [the compilation issue](https://github.com/KLayout/klayout/issues/1599).
I have also tried migrating to "Python 3.12.x" (earlier, Python 3.11.x) in this version.
# 3. Script language support: Ruby and Python
The build script **`build4mac.py`** provides several possible combinations of Qt, Ruby, and Python modules to suit the user's needs and preferences.
Some typical use cases are described in Section 6.
# 4. Prerequisites
You need to have the followings:
* The latest Xcode and command-line tool kit compliant with each OS
* https://developer.apple.com/xcode/resources/
* https://mac.install.guide/commandlinetools/4
* Qt5 package from MacPorts or Anaconda3. Qt6, from Homebrew.
* libgit2 form MacPorts, Homebrew,or Anaconda3.
* Optionally, Ruby and Python packages from MacPorts, Homebrew, or Anaconda3
#### For matching versions of Ruby and Python, please also refer to `build4mac_env.py`.
# 5. Command-line options of **`build4mac.py`**
**`build4mac.py`** is the top level Python script for building KLayout for a macOS.
The operating system type is detected automatically.
```
-----------------------------------------------------------------------------------------------------------
<< Usage of 'build4mac.py' >>
for building KLayout 0.30.2 or later on different Apple macOS platforms.
$ [python] ./build4mac.py
option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details) | default value
----------------------------------------------------------------------------------------+---------------
[-q|--qt ] : case-insensitive type=['Qt5MacPorts', 'Qt5Brew', 'Qt5Ana3', | qt5macports
: 'Qt6MacPorts', 'Qt6Brew'] |
: Qt5MacPorts: use Qt5 from MacPorts |
: Qt5Brew: use Qt5 from Homebrew |
: Qt5Ana3: use Qt5 from Anaconda3 |
: Qt6MacPorts: use Qt6 from MacPorts (*) |
: Qt6Brew: use Qt6 from Homebrew (*) |
: (*) migration to Qt6 is ongoing |
[-r|--ruby ] : case-insensitive type=['nil', 'Sys', 'MP33', 'HB34', 'Ana3'] | sys
: nil: don't bind Ruby |
: Sys: use [Sequoia|Sonoma|Ventura|Monterey]-bundled Ruby 2.6 |
: MP33: use Ruby 3.3 from MacPorts |
: HB34: use Ruby 3.4 from Homebrew |
: Ana3: use Ruby 3.2 from Anaconda3 |
[-p|--python ] : case-insensitive type=['nil', 'Sys', 'MP312', 'HB312', 'Ana3', | sys
: 'MP311', 'HB311', 'HBAuto'] |
: nil: don't bind Python |
: Sys: use [Sequoia|Sonoma|Ventura|Monterey]-bundled Python 3.9 |
: MP312: use Python 3.12 from MacPorts |
: HB312: use Python 3.12 from Homebrew |
: Ana3: use Python 3.12 from Anaconda3 |
: MP311: use Python 3.11 from MacPorts |
: HB311: use Python 3.11 from Homebrew (+) |
: (+) required to provide the legacy pip in HW-*.dmg |
: HBAuto: use the latest Python 3.x auto-detected from Homebrew |
[-P|--buildPymod] : build and deploy Pymod (*.whl) for LW-*.dmg | disabled
[-n|--noqtbinding] : don't create Qt bindings for ruby scripts | disabled
[-u|--noqtuitools] : don't include uitools in Qt binding | disabled
[-g|--nolibgit2] : don't include libgit2 for Git package support | disabled
[-m|--make