Skip to content

Commit

Permalink
python3Packages.pyobkc-frameworks-*: Fix issues when sandbox is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Dec 25, 2020
1 parent 53b3aad commit 852c2c6
Show file tree
Hide file tree
Showing 114 changed files with 2,235 additions and 581 deletions.
35 changes: 22 additions & 13 deletions pkgs/development/python-modules/pyobjc-core/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, cffi, setuptools, python }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, cffi, setuptools}:

buildPythonPackage rec {
pname = "pyobjc-core";
Expand All @@ -14,9 +14,11 @@ buildPythonPackage rec {
postPatch = ''
# Hard code correct SDK version
# Fix hardcoded paths
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace setup.py \
--replace 'get_sdk_level(self.sdk_root)' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os.path.join(self.sdk_root, "usr/include/objc/runtime.h")' '"${darwin.objc4}/include/objc/runtime.h"'
--replace 'os.path.join(self.sdk_root, "usr/include/objc/runtime.h")' '"${darwin.objc4}/include/objc/runtime.h"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["true"]'
# Hard code OS version
# This needs to be done here or pyobjc-frameworks-* don't get the change
Expand All @@ -32,15 +34,17 @@ buildPythonPackage rec {
Foundation
]);

propagatedBuildInputs = with darwin; [
objc4
] ++ [
propagatedBuildInputs = [
# required for namespaced import of PyObjCTools.TestSupport from pyobjc-framework-*
setuptools
];

hardeningDisable = [ "strictoverflow" ];

preBuild = ''
export SDKROOT=/
'';

preCheck = ''
# Test removed because ~ does not expand to /homeless-shelter
rm PyObjCTest/test_bundleFunctions.py
Expand All @@ -57,6 +61,12 @@ buildPythonPackage rec {
substituteInPlace PyObjCTest/test_testsupport.py \
--replace '".".join(platform.mac_ver()[0].split("."))' '"${darwin.apple_sdk.sdk.version}"'
# Tries to acces paths outside the sandbox
rm PyObjCTest/test_filepointer.py PyObjCTest/test_fsref.py
# Segmentation fault: 11
rm PyObjCTest/test_corefoundation.py
'';

# show test names instead of just dots
Expand All @@ -68,12 +78,11 @@ buildPythonPackage rec {
runHook postCheck
'';

meta = with stdenv.lib;
{
description = "Python<->ObjC Interoperability Module";
homepage = "https://pythonhosted.org/pyobjc-core/";
license = licenses.mit;
maintainers = with maintainers; [ SuperSandro2000 ];
platforms = platforms.darwin;
};
meta = with stdenv.lib; {
description = "Python<->ObjC Interoperability Module";
homepage = "https://pythonhosted.org/pyobjc-core/";
license = licenses.mit;
maintainers = with maintainers; [ SuperSandro2000 ];
platforms = platforms.darwin;
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa, pyobjc-framework-CoreMedia, pyobjc-framework-Quartz }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa, pyobjc-framework-CoreMedia, pyobjc-framework-Quartz }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AVFoundation/__init__.py \
--replace '/System/Library/Frameworks/AVFoundation.framework' "${darwin.apple_sdk.frameworks.AVFoundation}/Library/Frameworks/AVFoundation.framework"
'';

buildInputs = with darwin.apple_sdk.frameworks; [
Expand Down Expand Up @@ -48,11 +58,21 @@ buildPythonPackage rec {
preCheck = ''
# testConstants in PyObjCTest.test_cfsocket.TestSocket returns: Segmentation fault: 11
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
# AttributeError: AVAudioMake3DPoint
rm PyObjCTest/test_avaudiotypes.py
# AttributeError: AVMakeBeatRange
rm PyObjCTest/test_avaudiosequencer.py
# Remove Test which is probably missing a sdk check
substituteInPlace PyObjCTest/test_avcapturedevice.py \
--replace 'def testMissingConstants(self):' 'def disabled_testMissingConstants(self):'
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AVFoundation" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AVFoundation on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AVFoundation/";
Expand Down
24 changes: 20 additions & 4 deletions pkgs/development/python-modules/pyobjc-framework-AVKit/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Quartz }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Quartz }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AVKit/__init__.py \
--replace '/System/Library/Frameworks/AVKit.framework' "${darwin.apple_sdk.frameworks.AVKit}/Library/Frameworks/AVKit.framework"
'';

buildInputs = with darwin.apple_sdk.frameworks; [
Expand Down Expand Up @@ -46,8 +56,14 @@ buildPythonPackage rec {
preCheck = ''
# testConstants in PyObjCTest.test_cfsocket.TestSocket returns: Segmentation fault: 11
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
# objc.ProtocolError: ("protocol 'AVCaptureViewDelegate' does not exist", 'AVCaptureViewDelegate')
rm PyObjCTest/test_avcaptureview.py
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AVKit" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AVKit on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AVKit/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/Accounts/__init__.py \
--replace '/System/Library/Frameworks/Accounts.framework' "${darwin.apple_sdk.frameworks.Accounts}/Library/Frameworks/Accounts.framework"
'';

propagatedBuildInputs = [
Expand All @@ -43,6 +53,10 @@ buildPythonPackage rec {
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "Accounts" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework Accounts on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-Accounts/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AdSupport/__init__.py \
--replace '/System/Library/Frameworks/AdSupport.framework' "${darwin.apple_sdk.frameworks.AdSupport}/Library/Frameworks/AdSupport.framework"
'';

propagatedBuildInputs = [
Expand All @@ -43,6 +53,10 @@ buildPythonPackage rec {
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AdSupport" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AdSupport on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AdSupport/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AddressBook/__init__.py \
--replace '/System/Library/Frameworks/AddressBook.framework' "${darwin.apple_sdk.frameworks.AddressBook}/Library/Frameworks/AddressBook.framework"
'';

buildInputs = with darwin.apple_sdk.frameworks; [
Expand Down Expand Up @@ -57,8 +67,18 @@ buildPythonPackage rec {
# Set correct SDK version
substituteInPlace PyObjCTest/test_abglobals.py \
--replace 'def testConstants_10_7_broken(self):' 'def disabled_testConstants_10_7_broken(self):'
# Crash in sandbox: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Critical error: required built-in appearance SystemAppearance not found'
rm PyObjCTest/test_abpeoplepickerc.py
# objc.ProtocolError: ("protocol 'ABPersonPickerDelegate' does not exist", 'ABPersonPickerDelegate')
rm PyObjCTest/test_abpersonpickerdelegate.py
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AddressBook" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AddressBook on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AddressBook/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AppleScriptKit/__init__.py \
--replace '/System/Library/Frameworks/AppleScriptKit.framework' "${darwin.apple_sdk.frameworks.AppleScriptKit}/Library/Frameworks/AppleScriptKit.framework"
'';

propagatedBuildInputs = [
Expand All @@ -43,6 +53,10 @@ buildPythonPackage rec {
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AppleScriptKit" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AppleScriptKit on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AppleScriptKit/";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python,
pyobjc-core, pyobjc-framework-Cocoa }:
{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, darwin, python, xcodebuild
, pyobjc-core, pyobjc-framework-Cocoa }:

# This file is generated by pkgs/development/python-modules/pyobjc/update.sh. Please don't modify it directly.
# If you need help please contact a maintainer of pyobjc.
Expand All @@ -16,9 +16,19 @@ buildPythonPackage rec {
};

postPatch = ''
# Hard code correct SDK version
# Hardcode correct SDK version
# Remove xcrun call, all paths are provided by nix anyway
substituteInPlace pyobjc_setup.py \
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"'
--replace 'os.path.basename(data)[6:-4]' '"${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_os_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level = get_sdk_level()' 'os_level = "${darwin.apple_sdk.sdk.version}"' \
--replace 'os_level.split' '"${darwin.apple_sdk.sdk.version}".split' \
--replace 'return get_os_level()' 'return "${darwin.apple_sdk.sdk.version}"' \
--replace '["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"]' '["echo", "${xcodebuild.sdk}.sdk"]'
# Import Nix Framework instead of system one
substituteInPlace Lib/AppleScriptObjC/__init__.py \
--replace '/System/Library/Frameworks/AppleScriptObjC.framework' "${darwin.apple_sdk.frameworks.AppleScriptObjC}/Library/Frameworks/AppleScriptObjC.framework"
'';

propagatedBuildInputs = [
Expand All @@ -43,6 +53,10 @@ buildPythonPackage rec {
export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks
'';

# fails with
# Assertion failed: (stat(path, &stat_data) == 0), function _open_and_mmap_for_reading, file /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/LanguageIdentifier/LanguageIdentifier-133/LanguageIdentifier.c, line 621.
# pythonImportsCheck = [ "AppleScriptObjC" ];

meta = with stdenv.lib; {
description = "Wrappers for the framework AppleScriptObjC on Mac OS X";
homepage = "https://pythonhosted.org/pyobjc-framework-AppleScriptObjC/";
Expand Down
Loading

0 comments on commit 852c2c6

Please sign in to comment.