Merge pull request #1318 from Kazzz-S/0.28.6-mac1

Updated the build system for macOS to build KLayout version 0.28.6
This commit is contained in:
Matthias Köfferlein 2023-03-20 14:03:58 +01:00 committed by GitHub
commit c6bfb03a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 21 deletions

View File

@ -1,9 +1,9 @@
Relevant KLayout version: 0.28.4<br> Relevant KLayout version: 0.28.6<br>
Author: Kazzz-S<br> Author: Kazzz-S<br>
Last modified: 2023-02-01<br> Last modified: 2023-03-19<br>
# 1. Introduction # 1. Introduction
This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.28.4 or later for different 64-bit macOS, including: This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.28.6 or later for different 64-bit macOS, including:
* Catalina (10.15.7) : the primary development environment * Catalina (10.15.7) : the primary development environment
* Big Sur (11.x) : experimental; Apple (M1|M2) chip is not tested since the author does not own an (M1|M2) Mac * Big Sur (11.x) : experimental; Apple (M1|M2) chip is not tested since the author does not own an (M1|M2) Mac
* Monterey (12.x) : -- ditto -- * Monterey (12.x) : -- ditto --
@ -73,7 +73,7 @@ You need to have the followings:
``` ```
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
<< Usage of 'build4mac.py' >> << Usage of 'build4mac.py' >>
for building KLayout 0.28.4 or later on different Apple macOS / Mac OSX platforms. for building KLayout 0.28.6 or later on different Apple macOS / Mac OSX platforms.
$ [python] ./build4mac.py $ [python] ./build4mac.py
option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value
@ -130,7 +130,7 @@ $ [python] ./build4mac.py
``` ```
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
<< Usage of 'build4mac.py' >> << Usage of 'build4mac.py' >>
for building KLayout 0.28.4 or later on different Apple macOS / Mac OSX platforms. for building KLayout 0.28.6 or later on different Apple macOS / Mac OSX platforms.
$ [python] ./build4mac.py $ [python] ./build4mac.py
option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value
@ -236,7 +236,7 @@ $ ./build4mac.py -q qt5macports -r mp32 -p mp39
2. Confirm successful build (it will take about one hour, depending on your machine spec). 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> 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> The buddy command-line tools (strm*) will also be deployed under **klayout.app/Contents/Buddy/** in this step.<br>
If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl, \*.egg) will be built and deployed under **klayout.app/Contents/pymod-dist/**. If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl) will be built and deployed under **klayout.app/Contents/pymod-dist/**.
``` ```
$ ./build4mac.py -q qt5macports -r mp32 -p mp39 -Y $ ./build4mac.py -q qt5macports -r mp32 -p mp39 -Y
@ -263,7 +263,7 @@ $ ./build4mac.py -q qt5brew -r hb32 -p hb39
2. Confirm successful build (it will take about one hour, depending on your machine spec). 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> 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> The buddy command-line tools (strm*) will also be deployed under **klayout.app/Contents/Buddy/** in this step.<br>
If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl, \*.egg) will be built and deployed under **klayout.app/Contents/pymod-dist/**. If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl) will be built and deployed under **klayout.app/Contents/pymod-dist/**.
``` ```
$ ./build4mac.py -q qt5brew -r hb32 -p hb39 -Y $ ./build4mac.py -q qt5brew -r hb32 -p hb39 -Y
@ -316,7 +316,7 @@ $ ./build4mac.py -q qt5ana3 -r ana3 -p ana3
2. Confirm successful build (it will take about one hour, depending on your machine spec). 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> 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> The buddy command-line tools (strm*) will also be deployed under **klayout.app/Contents/Buddy/** in this step.<br>
If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl, \*.egg) will be built and deployed under **klayout.app/Contents/pymod-dist/**. If you use `--buildPymod` option in Step-1 and Step-3, the KLayout Python Module (\*.whl) will be built and deployed under **klayout.app/Contents/pymod-dist/**.
``` ```
$ ./build4mac.py -q qt5ana3 -r ana3 -p ana3 -Y $ ./build4mac.py -q qt5ana3 -r ana3 -p ana3 -Y
@ -352,8 +352,8 @@ $ cd /where/'build.sh'/exists
$ ./makeDMG4mac.py -p LW-qt5MP.pkg.macos-Catalina-release-Rmp32Pmp39 -m $ ./makeDMG4mac.py -p LW-qt5MP.pkg.macos-Catalina-release-Rmp32Pmp39 -m
``` ```
This command will generate the two files below:<br> This command will generate the two files below:<br>
* **`LW-klayout-0.28.4-macOS-Catalina-1-qt5MP-Rmp32Pmp39.dmg`** ---(1) the main DMG file * **`LW-klayout-0.28.6-macOS-Catalina-1-qt5MP-Rmp32Pmp39.dmg`** ---(1) the main DMG file
* **`LW-klayout-0.28.4-macOS-Catalina-1-qt5MP-Rmp32Pmp39.dmg.md5`** ---(2) MD5-value text file * **`LW-klayout-0.28.6-macOS-Catalina-1-qt5MP-Rmp32Pmp39.dmg.md5`** ---(2) MD5-value text file
# Known issues # Known issues
Because we assume some specific versions of non-OS-standard Ruby and Python, updating MacPorts, Homebrew, or Anaconda3 may cause build- and link errors.<br> Because we assume some specific versions of non-OS-standard Ruby and Python, updating MacPorts, Homebrew, or Anaconda3 may cause build- and link errors.<br>

View File

@ -47,7 +47,7 @@ def GenerateUsage(platform):
usage = "\n" usage = "\n"
usage += "---------------------------------------------------------------------------------------------------------\n" usage += "---------------------------------------------------------------------------------------------------------\n"
usage += "<< Usage of 'build4mac.py' >>\n" usage += "<< Usage of 'build4mac.py' >>\n"
usage += " for building KLayout 0.28.4 or later on different Apple macOS / Mac OSX platforms.\n" usage += " for building KLayout 0.28.6 or later on different Apple macOS / Mac OSX platforms.\n"
usage += "\n" usage += "\n"
usage += "$ [python] ./build4mac.py\n" usage += "$ [python] ./build4mac.py\n"
usage += " option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value\n" usage += " option & argument : descriptions (refer to 'macbuild/build4mac_env.py' for details)| default value\n"
@ -905,19 +905,31 @@ def Build_pymod(parameters):
PymodDistDir = parameters['pymod_dist'] PymodDistDir = parameters['pymod_dist']
# Using MacPorts # Using MacPorts
if PymodDistDir[ModulePython] == 'dist-MP3': if PymodDistDir[ModulePython] == 'dist-MP3':
addBinPath = "/opt/local/bin"
addIncPath = "/opt/local/include" addIncPath = "/opt/local/include"
addLibPath = "/opt/local/lib" addLibPath = "/opt/local/lib"
# Using Homebrew # Using Homebrew
elif PymodDistDir[ModulePython] == 'dist-HB3': elif PymodDistDir[ModulePython] == 'dist-HB3':
addIncPath = "%s/include" % DefaultHomebrewRoot # defined in "build4mac_env.py" addBinPath = "%s/bin" % DefaultHomebrewRoot # defined in "build4mac_env.py"
addLibPath = "%s/lib" % DefaultHomebrewRoot # defined in "build4mac_env.py" addIncPath = "%s/include" % DefaultHomebrewRoot # -- ditto --
addLibPath = "%s/lib" % DefaultHomebrewRoot # -- ditto --
elif PymodDistDir[ModulePython] == 'dist-ana3': elif PymodDistDir[ModulePython] == 'dist-ana3':
addBinPath = "/Applications/anaconda3/bin"
addIncPath = "/Applications/anaconda3/include" addIncPath = "/Applications/anaconda3/include"
addLibPath = "/Applications/anaconda3/lib" addLibPath = "/Applications/anaconda3/lib"
else: else:
addBinPath = ""
addIncPath = "" addIncPath = ""
addLibPath = "" addLibPath = ""
if not addBinPath == "":
try:
bpath = os.environ['PATH']
except KeyError:
os.environ['PATH'] = addBinPath
else:
os.environ['PATH'] = "%s:%s" % (addBinPath, bpath)
if not addIncPath == "": if not addIncPath == "":
try: try:
cpath = os.environ['CPATH'] cpath = os.environ['CPATH']
@ -937,10 +949,11 @@ def Build_pymod(parameters):
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# [3] Set different command line parameters for building <pymod> # [3] Set different command line parameters for building <pymod>
#-------------------------------------------------------------------- #--------------------------------------------------------------------
cmd1_args = " setup.py build \\\n" cmd1_args = " -m setup build \\\n"
cmd2_args = " setup.py bdist_wheel \\\n" cmd2_args = " -m setup bdist_wheel \\\n"
cmd3_args = " setup.py bdist_egg \\\n" deloc_cmd = " delocate-wheel --ignore-missing-dependencies"
cmd4_args = " setup.py clean --all \\\n" cmd3_args = " <wheel file> \\\n"
cmd4_args = " -m setup clean --all \\\n"
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# [4] Make the consolidated command lines # [4] Make the consolidated command lines
@ -958,7 +971,7 @@ def Build_pymod(parameters):
command2 += " test ${PIPESTATUS[0]} -eq 0" # tee always exits with 0 command2 += " test ${PIPESTATUS[0]} -eq 0" # tee always exits with 0
command3 = "time" command3 = "time"
command3 += " \\\n %s \\\n" % parameters['python'] command3 += " \\\n %s \\\n" % deloc_cmd
command3 += cmd3_args command3 += cmd3_args
command3 += " 2>&1 | tee -a %s; \\\n" % parameters['logfile'] command3 += " 2>&1 | tee -a %s; \\\n" % parameters['logfile']
command3 += " test ${PIPESTATUS[0]} -eq 0" # tee always exits with 0 command3 += " test ${PIPESTATUS[0]} -eq 0" # tee always exits with 0
@ -986,6 +999,7 @@ def Build_pymod(parameters):
print( "<Stage-4>") print( "<Stage-4>")
print( " ", command4 ) print( " ", command4 )
print( "" ) print( "" )
if parameters['check_cmd_only']: if parameters['check_cmd_only']:
return 0 return 0
@ -1011,11 +1025,26 @@ def Build_pymod(parameters):
print( "", file=sys.stderr ) print( "", file=sys.stderr )
return 1 return 1
ret = subprocess.call( command3, shell=True ) #---------------------------------------------------------------------------------------------------------
# Copy and relink library dependencies for wheel.
# In this step, the "delocate-wheel" command using the desired Python must be found in the PATH.
# Refer to: https://github.com/Kazzz-S/klayout/issues/49#issuecomment-1432154118
# https://pypi.org/project/delocate/
#---------------------------------------------------------------------------------------------------------
cmd3_args = glob.glob( "dist/*.whl" ) # like ['dist/klayout-0.28.6-cp39-cp39-macosx_12_0_x86_64.whl']
if len(cmd3_args) == 1:
command3 = "time"
command3 += " \\\n %s \\\n" % deloc_cmd
command3 += " %s \\\n" % cmd3_args[0]
command3 += " 2>&1 | tee -a %s; \\\n" % parameters['logfile']
command3 += " test ${PIPESTATUS[0]} -eq 0" # tee always exits with 0
ret = subprocess.call( command3, shell=True )
else:
ret = 1
if ret != 0: if ret != 0:
print( "", file=sys.stderr ) print( "", file=sys.stderr )
print( "-------------------------------------------------------------", file=sys.stderr ) print( "-------------------------------------------------------------", file=sys.stderr )
print( "!!! <%s>: failed to build <pymod-egg>" % myscript, file=sys.stderr ) print( "!!! <%s>: failed to <delocate-wheel>" % myscript, file=sys.stderr )
print( "-------------------------------------------------------------", file=sys.stderr ) print( "-------------------------------------------------------------", file=sys.stderr )
print( "", file=sys.stderr ) print( "", file=sys.stderr )
return 1 return 1

View File

@ -196,7 +196,7 @@ Ruby31MacPorts = { 'exe': '/opt/local/bin/ruby3.1',
# install with 'sudo port install ruby32' # install with 'sudo port install ruby32'
# [Key Type Name] = 'MP32' # [Key Type Name] = 'MP32'
Ruby32MacPorts = { 'exe': '/opt/local/bin/ruby3.2', Ruby32MacPorts = { 'exe': '/opt/local/bin/ruby3.2',
'inc': '/opt/local/include/ruby-3.2.0', 'inc': '/opt/local/include/ruby-3.2.1',
'lib': '/opt/local/lib/libruby.3.2.dylib' 'lib': '/opt/local/lib/libruby.3.2.dylib'
} }