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

Using the Ruby 3.4 from Homebrew #1979

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions macbuild/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Relevant KLayout version: 0.29.7<br>
Relevant KLayout version: 0.29.11<br>
Author: Kazzz-S<br>
Last modified: 2024-09-23<br>
Last modified: 2025-01-19<br>

# 1. Introduction
This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.29.7 or later for different 64-bit macOS, including:
This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.29.11 or later for different 64-bit macOS, including:
* Sonoma (14.x) : the primary development environment
* Ventura (13.x) : experimental
* Sequoia (15.x) : -- ditto --
Expand All @@ -19,7 +19,7 @@ Pre-built DMG packages are also not provided.<br>
* El Capitan (10.11)

Throughout this document, the primary target machine is **Intel x86_64** with **macOS Sonoma**.<br>
All Apple (M1|M2|M3) chips are still untested, as the author does not own an (M1|M2|M3) Mac.<br>
All Apple (M1|M2|M3|M4) chips are still untested, as the author does not own an (M1|M2|M3|M4) Mac.<br>
However, some kind volunteers told me they successfully built on an Apple silicon machine.<br>

# 2. Qt Frameworks
Expand Down Expand Up @@ -70,7 +70,7 @@ The operating system type is detected automatically.
```
-----------------------------------------------------------------------------------------------------------
<< Usage of 'build4mac.py' >>
for building KLayout 0.29.7 or later on different Apple macOS platforms.
for building KLayout 0.29.11 or later on different Apple macOS platforms.

$ [python] ./build4mac.py
option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details) | default value
Expand All @@ -83,11 +83,11 @@ $ [python] ./build4mac.py
: Qt6MacPorts: use Qt6 from MacPorts (*) |
: Qt6Brew: use Qt6 from Homebrew (*) |
: (*) migration to Qt6 is ongoing |
[-r|--ruby <type>] : case-insensitive type=['nil', 'Sys', 'MP33', 'HB33', 'Ana3'] | sys
[-r|--ruby <type>] : 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 |
: HB33: use Ruby 3.3 from Homebrew |
: HB34: use Ruby 3.4 from Homebrew |
: Ana3: use Ruby 3.2 from Anaconda3 |
[-p|--python <type>] : case-insensitive type=['nil', 'Sys', 'MP312', 'HB312', 'Ana3', | sys
: 'MP311', 'HB311', 'HBAuto'] |
Expand Down Expand Up @@ -195,10 +195,10 @@ $ ./build4mac.py -q qt5macports -r mp33 -p mp312 -Y
> [!IMPORTANT]
> To build KLayout >= 0.29.0, you need "Qt6" >= 6.7.0 to address [the compilation issue](https://github.com/KLayout/klayout/issues/1599).<br>

0. Install Homebrew, then install Qt6, Ruby 3.3, Python 3.12, and libgit2 by
0. Install Homebrew, then install Qt6, Ruby 3.4, Python 3.12, and libgit2 by
```
$ brew install qt@6
$ brew install ruby@3.3
$ brew install ruby@3.4
$ brew install [email protected]
$ brew install libgit2
$ cd /where/'build.sh'/exists
Expand All @@ -208,20 +208,20 @@ $ ./python3HB.py -v 3.12
1. Invoke **`build4mac.py`** with the following options:
```
$ cd /where/'build.sh'/exists
$ ./build4mac.py -q qt6brew -r hb33 -p hb312
$ ./build4mac.py -q qt6brew -r hb34 -p hb312
```
2. Confirm successful build (it will take about one hour, depending on your machine spec).
3. Rerun **`build4mac.py`** with the same options used in 1. PLUS "-Y" to deploy executables and libraries under **`klayout.app`** bundle.<br>
The buddy command-line tools (strm*) will also be deployed under **klayout.app/Contents/Buddy/** in this step.<br>

```
$ ./build4mac.py -q qt6brew -r hb33 -p hb312 -Y
$ ./build4mac.py -q qt6brew -r hb34 -p hb312 -Y
```
The application bundle **`klayout.app`** is located under:<br>
**`LW-qt6Brew.pkg.macos-Sonoma-release-Rhb33Phb312`** directory, where
**`LW-qt6Brew.pkg.macos-Sonoma-release-Rhb34Phb312`** directory, where
* "LW-" means this is a lightweight package.
* "qt6Brew" means that Qt6 from Homebrew is used.
* "Rhb33Phb312" means that Ruby is 3.3 from Homebrew; Python is 3.12 from Homebrew.
* "Rhb34Phb312" means that Ruby is 3.4 from Homebrew; Python is 3.12 from Homebrew.
4. Copy/move the generated application bundle **`klayout.app`** to your **`/Applications`** directory for installation.

> [!WARNING]
Expand Down Expand Up @@ -397,8 +397,8 @@ $ cd /where/'build.sh'/exists
$ ./makeDMG4mac.py -p LW-qt5MP.pkg.macos-Sonoma-release-Rmp33Pmp312 -m
```
This command will generate the two files below:<br>
* **`LW-klayout-0.29.7-macOS-Sonoma-1-qt5MP-Rmp33Pmp312.dmg`** ---(1) the main DMG file
* **`LW-klayout-0.29.7-macOS-Sonoma-1-qt5MP-Rmp33Pmp312.dmg.md5`** ---(2) MD5-value text file
* **`LW-klayout-0.29.11-macOS-Sonoma-1-qt5MP-Rmp33Pmp312.dmg`** ---(1) the main DMG file
* **`LW-klayout-0.29.11-macOS-Sonoma-1-qt5MP-Rmp33Pmp312.dmg.md5`** ---(2) MD5-value text file

# Known issues
Because we assume some specific versions of non-OS-standard Ruby and Python, updating Homebrew, MacPorts, or Anaconda3 may cause build- and link errors.<br>
Expand Down
Binary file modified macbuild/Resources/script-bundle-B.zip
Binary file not shown.
28 changes: 14 additions & 14 deletions macbuild/build4mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# File: "macbuild/build4mac.py"
#
# The top Python script for building KLayout (http://www.klayout.de/index.php)
# version 0.29.7 or later on different Apple Mac OSX platforms.
# version 0.29.11 or later on different Apple Mac OSX platforms.
#===============================================================================
import sys
import os
Expand Down Expand Up @@ -45,7 +45,7 @@ def GenerateUsage(platform):
usage = "\n"
usage += "-----------------------------------------------------------------------------------------------------------\n"
usage += "<< Usage of 'build4mac.py' >>\n"
usage += " for building KLayout 0.29.7 or later on different Apple macOS platforms.\n"
usage += " for building KLayout 0.29.11 or later on different Apple macOS platforms.\n"
usage += "\n"
usage += "$ [python] ./build4mac.py\n"
usage += " option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details) | default value\n"
Expand All @@ -58,11 +58,11 @@ def GenerateUsage(platform):
usage += " : Qt6MacPorts: use Qt6 from MacPorts (*) |\n"
usage += " : Qt6Brew: use Qt6 from Homebrew (*) |\n"
usage += " : (*) migration to Qt6 is ongoing |\n"
usage += " [-r|--ruby <type>] : case-insensitive type=['nil', 'Sys', 'MP33', 'HB33', 'Ana3'] | %s\n" % myRuby
usage += " [-r|--ruby <type>] : case-insensitive type=['nil', 'Sys', 'MP33', 'HB34', 'Ana3'] | %s\n" % myRuby
usage += " : nil: don't bind Ruby |\n"
usage += " : Sys: use [Sequoia|Sonoma|Ventura|Monterey]-bundled Ruby 2.6 |\n"
usage += " : MP33: use Ruby 3.3 from MacPorts |\n"
usage += " : HB33: use Ruby 3.3 from Homebrew |\n"
usage += " : HB34: use Ruby 3.4 from Homebrew |\n"
usage += " : Ana3: use Ruby 3.2 from Anaconda3 |\n"
usage += " [-p|--python <type>] : case-insensitive type=['nil', 'Sys', 'MP312', 'HB312', 'Ana3', | %s\n" % myPython
usage += " : 'MP311', 'HB311', 'HBAuto'] |\n"
Expand Down Expand Up @@ -271,7 +271,7 @@ def Parse_CLI_Args(config):

p.add_option( '-r', '--ruby',
dest='type_ruby',
help="Ruby type=['nil', 'Sys', 'MP33', 'HB33', 'Ana3']" )
help="Ruby type=['nil', 'Sys', 'MP33', 'HB34', 'Ana3']" )

p.add_option( '-p', '--python',
dest='type_python',
Expand Down Expand Up @@ -405,7 +405,7 @@ def Parse_CLI_Args(config):
candidates['NIL'] = 'nil'
candidates['SYS'] = 'Sys'
candidates['MP33'] = 'MP33'
candidates['HB33'] = 'HB33'
candidates['HB34'] = 'HB34'
candidates['ANA3'] = 'Ana3'
try:
choiceRuby = candidates[ opt.type_ruby.upper() ]
Expand All @@ -428,8 +428,8 @@ def Parse_CLI_Args(config):
elif choiceRuby == "MP33":
ModuleRuby = 'Ruby33MacPorts'
NonOSStdLang = True
elif choiceRuby == "HB33":
ModuleRuby = 'Ruby33Brew'
elif choiceRuby == "HB34":
ModuleRuby = 'Ruby34Brew'
NonOSStdLang = True
elif choiceRuby == "Ana3":
ModuleRuby = 'RubyAnaconda3'
Expand Down Expand Up @@ -730,7 +730,7 @@ def Get_Build_Parameters(config):
# <pymod> will be built if:
# BuildPymodWhl = True
# Platform = [ 'Sequoia', 'Sonoma', 'Ventura', 'Monterey']
# ModuleRuby = [ 'Ruby33MacPorts', 'Ruby33Brew', 'RubyAnaconda3' ]
# ModuleRuby = [ 'Ruby33MacPorts', 'Ruby34Brew', 'RubyAnaconda3' ]
# ModulePython = [ 'Python312MacPorts', 'Python311MacPorts',
# 'Python311Brew',
# 'PythonAnaconda3' ]
Expand All @@ -741,7 +741,7 @@ def Get_Build_Parameters(config):

PymodDistDir = dict()
if Platform in [ 'Sequoia', 'Sonoma', 'Ventura', 'Monterey' ]:
if ModuleRuby in [ 'Ruby33MacPorts', 'Ruby33Brew', 'RubyAnaconda3' ]:
if ModuleRuby in [ 'Ruby33MacPorts', 'Ruby34Brew', 'RubyAnaconda3' ]:
if ModulePython in [ 'Python312MacPorts', 'Python311MacPorts' ]:
PymodDistDir[ModulePython] = 'dist-MP3-%s' % ModuleQt
elif ModulePython in [ 'Python311Brew' ]:
Expand All @@ -764,7 +764,7 @@ def Build_pymod_wheel(parameters):
# [1] <pymod> will be built if:
# BuildPymodWhl = True
# Platform = [ 'Sequoia', 'Sonoma', 'Ventura', 'Monterey']
# ModuleRuby = [ 'Ruby33MacPorts', 'Ruby33Brew', 'RubyAnaconda3' ]
# ModuleRuby = [ 'Ruby33MacPorts', 'Ruby34Brew', 'RubyAnaconda3' ]
# ModulePython = [ 'Python312MacPorts', 'Python311MacPorts',
# 'Python311Brew',
# 'PythonAnaconda3' ]
Expand All @@ -777,7 +777,7 @@ def Build_pymod_wheel(parameters):
return 0
if not Platform in [ 'Sequoia', 'Sonoma', 'Ventura', 'Monterey' ]:
return 0
elif not ModuleRuby in [ 'Ruby33MacPorts', 'Ruby33Brew', 'RubyAnaconda3' ]:
elif not ModuleRuby in [ 'Ruby33MacPorts', 'Ruby34Brew', 'RubyAnaconda3' ]:
return 0
elif not ModulePython in [ 'Python312MacPorts', 'Python311MacPorts', \
'Python311Brew', \
Expand Down Expand Up @@ -2158,11 +2158,11 @@ def Deploy_Binaries_For_Bundle(config, parameters):
#-------------------------------------------------------------
# [10] Special deployment of Ruby3.3 from Homebrew?
#-------------------------------------------------------------
deploymentRuby33HB = (ModuleRuby == 'Ruby33Brew')
deploymentRuby33HB = (ModuleRuby == 'Ruby34Brew')
if deploymentRuby33HB and NonOSStdLang:

print( "" )
print( " [10] You have reached optional deployment of Ruby from %s ..." % HBRuby33Path )
print( " [10] You have reached optional deployment of Ruby from %s ..." % HBRuby34Path )
print( " [!!!] Sorry, the deployed package will not work properly since deployment of" )
print( " Ruby3.3 from Homebrew is not yet supported." )
print( " Since you have Homebrew development environment, there two options:" )
Expand Down
20 changes: 10 additions & 10 deletions macbuild/build4mac_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Here are dictionaries of ...
# different modules for building KLayout (http://www.klayout.de/index.php)
# version 0.29.7 or later on different Apple Mac OSX platforms.
# version 0.29.11 or later on different Apple Mac OSX platforms.
#
# This file is imported by 'build4mac.py' script.
#===============================================================================
Expand Down Expand Up @@ -130,7 +130,7 @@
#-----------------------------------------------------
RubyNil = [ 'nil' ]
RubySys = [ 'RubyMonterey', 'RubyVentura', 'RubySonoma', 'RubySequoia' ]
RubyExt = [ 'Ruby33MacPorts', 'Ruby33Brew', 'RubyAnaconda3' ]
RubyExt = [ 'Ruby33MacPorts', 'Ruby34Brew', 'RubyAnaconda3' ]
Rubies = RubyNil + RubySys + RubyExt

#-----------------------------------------------------
Expand Down Expand Up @@ -196,13 +196,13 @@
'lib': '/opt/local/lib/libruby.3.3.dylib'
}

# Ruby 3.3 from Homebrew
# install with 'brew install ruby@3.3'
# [Key Type Name] = 'HB33'
HBRuby33Path = '%s/opt/ruby@3.3' % DefaultHomebrewRoot
Ruby33Brew = { 'exe': '%s/bin/ruby' % HBRuby33Path,
'inc': '%s/include/ruby-3.3.0' % HBRuby33Path,
'lib': '%s/lib/libruby.3.3.dylib' % HBRuby33Path
# Ruby 3.4 from Homebrew
# install with 'brew install ruby@3.4'
# [Key Type Name] = 'HB34'
HBRuby34Path = '%s/opt/ruby@3.4' % DefaultHomebrewRoot
Ruby34Brew = { 'exe': '%s/bin/ruby' % HBRuby34Path,
'inc': '%s/include/ruby-3.4.0' % HBRuby34Path,
'lib': '%s/lib/libruby.3.4.dylib' % HBRuby34Path
}

# Ruby 3.2 bundled with anaconda3 installed under /Applications/anaconda3/
Expand All @@ -221,7 +221,7 @@
'RubySonoma' : RubySonoma,
'RubySequoia' : RubySequoia,
'Ruby33MacPorts': Ruby33MacPorts,
'Ruby33Brew' : Ruby33Brew,
'Ruby34Brew' : Ruby34Brew,
'RubyAnaconda3' : RubyAnaconda3
}

Expand Down
12 changes: 6 additions & 6 deletions macbuild/makeDMG4mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def SetGlobals():
Usage = "\n"
Usage += "---------------------------------------------------------------------------------------------------------\n"
Usage += "<< Usage of 'makeDMG4mac.py' >>\n"
Usage += " for making a DMG file of KLayout 0.29.7 or later on different Apple macOS platforms.\n"
Usage += " for making a DMG file of KLayout 0.29.11 or later on different Apple macOS platforms.\n"
Usage += "\n"
Usage += "$ [python] ./makeDMG4mac.py\n"
Usage += " option & argument : descriptions | default value\n"
Expand Down Expand Up @@ -220,15 +220,15 @@ def SetGlobals():
# The package directory name should look like:
# * ST-qt5MP.pkg.macos-Sonoma-release-RsysPsys
# * LW-qt5Ana3.pkg.macos-Sonoma-release-Rana3Pana3
# * LW-qt6Brew.pkg.macos-Sonoma-release-Rhb33Phb312 --- (1)
# * LW-qt6Brew.pkg.macos-Sonoma-release-Rhb34Phb312 --- (1)
# * LW-qt5MP.pkg.macos-Sonoma-release-Rmp33Pmp312
# * HW-qt6Brew.pkg.macos-Sonoma-release-RsysPhb311
#
# * ST-qt6MP.pkg.macos-Sonoma-release-RsysPsys
# * LW-qt6MP.pkg.macos-Sonoma-release-Rmp33Pmp312
#
# Generated DMG will be, for example,
# (1) ---> LW-klayout-0.29.7-macOS-Sonoma-1-qt6Brew-Rhb33Phb312.dmg
# (1) ---> LW-klayout-0.29.7-macOS-Sonoma-1-qt6Brew-Rhb34Phb312.dmg
#
# @return on success, positive integer in [MB] that tells approx. occupied disc space;
# on failure, -1
Expand Down Expand Up @@ -270,10 +270,10 @@ def CheckPkgDirectory():
# [2] Identify (Qt, Ruby, Python) from PkgDir
# * ST-qt5MP.pkg.macos-Sonoma-release-RsysPsys
# * LW-qt5Ana3.pkg.macos-Sonoma-release-Rana3Pana3
# * LW-qt6Brew.pkg.macos-Sonoma-release-Rhb33Phb312
# * LW-qt6Brew.pkg.macos-Sonoma-release-Rhb34Phb312
# * LW-qt5MP.pkg.macos-Sonoma-release-Rmp33Pmp312
# * HW-qt6Brew.pkg.macos-Sonoma-release-RsysPhb311
# * EX-qt5MP.pkg.macos-Sonoma-release-Rhb33Pmp312
# * EX-qt5MP.pkg.macos-Sonoma-release-Rhb34Pmp312
#
# * ST-qt6MP.pkg.macos-Sonoma-release-RsysPsys
# * LW-qt6MP.pkg.macos-Sonoma-release-Rmp33Pmp312
Expand Down Expand Up @@ -324,7 +324,7 @@ def CheckPkgDirectory():
LatestOSHomebrew = Platform == LatestOS
LatestOSHomebrew &= PackagePrefix == "LW"
LatestOSHomebrew &= QtIdentification in [ "qt5Brew", "qt6Brew", "qt5MP", "qt6MP" ] # "qt[5|6]MP" are the alternatives
LatestOSHomebrew &= RubyPythonID in [ "Rhb33Phb312", "Rhb33Phb311", "Rhb33Phbauto" ]
LatestOSHomebrew &= RubyPythonID in [ "Rhb34Phb312", "Rhb34Phb311", "Rhb34Phbauto" ]

LatestOSAnaconda3 = Platform == LatestOS
LatestOSAnaconda3 &= PackagePrefix == "LW"
Expand Down
Loading
Loading