Skip to content

Commit

Permalink
[lang] Sign python library for Apple M1 (#7138)
Browse files Browse the repository at this point in the history
Apple requires any shared library built for Apple Silicon to be
codesigned with a local development certificate. This certificate is
generated by Xcode automatically.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PENGUINLIONG and pre-commit-ci[bot] authored Jan 13, 2023
1 parent 8eb30c2 commit cc21ab6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import platform
import shutil
import subprocess
import sys
from distutils.command.clean import clean
from distutils.dir_util import remove_tree
Expand Down Expand Up @@ -166,6 +167,22 @@ def cmake_install_manifest_filter(manifest_files):
]


def sign_development_for_apple_m1():
"""
Apple enforces codesigning for arm64 targets even for local development
builds. See discussion here:
https://github.com/supercollider/supercollider/issues/5603
"""
if sys.platform == "darwin" and platform.machine() == "arm64":
try:
for path in glob.glob("python/taichi/_lib/core/*.so"):
print(f"signing {path}..")
subprocess.check_call(
['codesign', '--force', '--deep', '--sign', '-', path])
except:
print("cannot sign python shared library for macos arm64 build")


copy_assets()
setup(name=project_name,
packages=packages,
Expand Down Expand Up @@ -198,3 +215,5 @@ def cmake_install_manifest_filter(manifest_files):
'clean': Clean
},
has_ext_modules=lambda: True)

sign_development_for_apple_m1()

0 comments on commit cc21ab6

Please sign in to comment.