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

Prevent installation on apple silicon without appropriate codesigned entitlements #698

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ jobs:

- name: (macOS) Setup test dependencies
if: matrix.os == 'macos-latest' || matrix.os == 'apple-silicon-m1'
run: brew install ant
run: |
brew install ant
codesign -dvvvv --xml --entitlements - $(which python) || true
codesign -dvvvv --xml --entitlements - $(which java) || true

- name: Build test classes via ant
run: ant all
Expand Down
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ def compile_native_invocation_handler(java):

compile_native_invocation_handler(JAVA)

def check_python_signing():
import platform
# check for mac
if sys.platform != 'darwin':
return
# check for arm
if platform.processor() != 'arm':
return
try:
codesign = subprocess.check_output(
['/usr/bin/codesign', '--display', '--verbose=4', '--xml', '--entitlements', '-',
sys.executable]
).decode("utf-8")
assert "com.apple.security.cs.disable-executable-page-protection" in codesign, (
("Python (%s) was not signed with com.apple.security.cs.disable-executable-page-protection entitlement. " % sys.executable) +
"You should installed a version of Python that has been codesigned with this entitlement.")
except:
assert False, (("Could not apply codesign to %s. Codesign is required for Apple Silicon. You should installed a version of " +
"Python installed that has been codesigned") % sys.executable)

check_python_signing()

# generate the config.pxi
with open(join(dirname(__file__), 'jnius', 'config.pxi'), 'w') as fd:
Expand Down
Loading