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

python3Packages.pyobjc: 7.0.1 -> 7.1 #118851

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
481 changes: 467 additions & 14 deletions pkgs/development/python-modules/pyobjc/default.nix

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions pkgs/development/python-modules/pyobjc/launch-services.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/pyobjc-framework-CoreServices/Lib/CoreServices/LaunchServices/__init__.py b/pyobjc-framework-CoreServices/Lib/CoreServices/LaunchServices/__init__.py
index d63c4532c..fcd9119c6 100644
--- a/pyobjc-framework-CoreServices/Lib/CoreServices/LaunchServices/__init__.py
+++ b/pyobjc-framework-CoreServices/Lib/CoreServices/LaunchServices/__init__.py
@@ -14,7 +14,7 @@ sys.modules["CoreServices.LaunchServices"] = mod = objc.ObjCLazyModule(
"LaunchServices",
"com.apple.CoreServices",
objc.pathForFramework(
- "/System/Library/Frameworks/CoreServices.framework/CoreServices"
+ "/System/Library/Frameworks/CoreServices.framework"
),
_metadata.__dict__,
None,
diff --git a/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py b/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py
index 2caaab5e6..0591c8b92 100644
--- a/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py
+++ b/pyobjc-framework-LaunchServices/Lib/LaunchServices/__init__.py
@@ -19,7 +19,7 @@ sys.modules["LaunchServices"] = mod = objc.ObjCLazyModule(
"LaunchServices",
"com.apple.CoreServices",
objc.pathForFramework(
- "/System/Library/Frameworks/CoreServices.framework/CoreServices"
+ "/System/Library/Frameworks/CoreServices.framework"
),
{},
None,
124 changes: 124 additions & 0 deletions pkgs/development/python-modules/pyobjc/macos-sdk-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
diff --git a/pyobjc-core/Tools/pyobjc_setup.py b/pyobjc-core/Tools/pyobjc_setup.py
index 669c77a79..dace5e3fd 100644
--- a/pyobjc-core/Tools/pyobjc_setup.py
+++ b/pyobjc-core/Tools/pyobjc_setup.py
@@ -204,46 +204,11 @@ def get_os_level():


def get_sdk():
- env_cflags = os.environ.get("CFLAGS", "")
- config_cflags = get_config_var("CFLAGS")
- sdk = None
- for cflags_str in [env_cflags, config_cflags]:
- cflags = shlex.split(cflags_str)
- for i, val in enumerate(cflags):
- if val == "-isysroot":
- sdk = cflags[i + 1]
- break
- elif val.find("-isysroot") == 0:
- sdk = val[len("-isysroot") :]
- break
- if sdk:
- break
-
- return sdk
+ return None


def get_sdk_level():
- sdk = get_sdk()
-
- if not sdk:
- return None
-
- if sdk == "/":
- return get_os_level()
-
- sdk = sdk.rstrip("/")
- sdkname = os.path.basename(sdk)
- assert sdkname.startswith("MacOSX")
- assert sdkname.endswith(".sdk")
- if sdkname == "MacOSX.sdk":
- try:
- with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
- pl = plistlib.load(fp)
- return pl["Version"]
- except Exception:
- raise SystemExit("Cannot determine SDK version")
- else:
- return sdkname[6:-4]
+ return os.environ["NIX_MACOS_SDK_VERSION"]


class pyobjc_install_lib(install_lib.install_lib):
@@ -418,39 +383,9 @@ def Extension(*args, **kwds):
if "clang" in get_config_var("CC"):
cflags.append("-Wno-deprecated-declarations")

- sdk = get_sdk()
- if not sdk:
- # We're likely on a system with the Xcode Command Line Tools.
- # Explicitly use the most recent SDK to avoid compile problems.
- data = subprocess.check_output(
- ["/usr/bin/xcrun", "-sdk", "macosx", "--show-sdk-path"],
- universal_newlines=True,
- ).strip()
-
- if data:
- sdk_settings_path = os.path.join(data, 'SDKSettings.plist')
- if os.path.exists(sdk_settings_path):
- with open(sdk_settings_path, 'rb') as fp:
- sdk_settings = plistlib.load(fp)
- version = sdk_settings['Version']
- else:
- version = os.path.basename(data)[6:-4]
-
- cflags.append("-isysroot")
- cflags.append(data)
- cflags.append(
- "-DPyObjC_BUILD_RELEASE=%02d%02d"
- % (tuple(map(int, version.split("."))))
- )
- else:
- cflags.append(
- "-DPyObjC_BUILD_RELEASE=%02d%02d" % (tuple(map(int, os_level.split("."))))
- )
-
- else:
- cflags.append(
- "-DPyObjC_BUILD_RELEASE=%02d%02d" % (tuple(map(int, os_level.split("."))))
- )
+ cflags.append(
+ "-DPyObjC_BUILD_RELEASE=%02d%02d" % (tuple(map(int, os_level.split("."))))
+ )

if os_level == "10.4":
cflags.append("-DNO_OBJC2_RUNTIME")
diff --git a/pyobjc-core/setup.py b/pyobjc-core/setup.py
index eb2ded7a4..48ef2dc59 100644
--- a/pyobjc-core/setup.py
+++ b/pyobjc-core/setup.py
@@ -42,22 +42,7 @@ def get_os_level():


def get_sdk_level(sdk):
- if sdk == "/":
- return get_os_level()
-
- sdk = sdk.rstrip("/")
- sdkname = os.path.basename(sdk)
- assert sdkname.startswith("MacOSX")
- assert sdkname.endswith(".sdk")
- if sdkname == "MacOSX.sdk":
- try:
- with open(os.path.join(sdk, "SDKSettings.plist"), "rb") as fp:
- pl = plistlib.load(fp)
- return pl["Version"]
- except Exception:
- raise SystemExit("Cannot determine SDK version")
- else:
- return sdkname[6:-4]
+ return os.environ["NIX_MACOS_SDK_VERSION"]


# CFLAGS for the objc._objc extension:
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/pyobjc/setup.py b/pyobjc/setup.py
index f9b5c3cc4..0ed41bdee 100644
--- a/pyobjc/setup.py
+++ b/pyobjc/setup.py
@@ -154,9 +154,6 @@ FRAMEWORK_WRAPPERS = [
("VideoToolbox", "10.8", None),
("Virtualization", "10.16", None),
("Vision", "10.13", None),
- # iTunes library is shipped with iTunes, not part of macOS 'core'
- # Requires iTunes 11 or later, which is not available on 10.5
- ("iTunesLibrary", "10.6", None),
]

MACOS_TO_DARWIN = {
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/pyobjc/setup.py b/pyobjc/setup.py
index df29c8316..f9b5c3cc4 100644
--- a/pyobjc/setup.py
+++ b/pyobjc/setup.py
@@ -9,6 +9,8 @@ import subprocess
import sys
import tarfile

+from packaging import version
+
from setuptools import setup, Command
from setuptools.command import egg_info

@@ -190,13 +192,23 @@ def framework_requires():

result = []

+ sdk_version = version.parse(os.environ["NIX_MACOS_SDK_VERSION"])
+
for name, introduced, removed in FRAMEWORK_WRAPPERS:

marker = []
if introduced is not None:
+ introduced_version = version.parse(introduced)
+ if introduced_version > sdk_version:
+ # nixpkgs hack: just skip things which don't match up with our SDK
+ continue
marker.append('platform_release>="%s"' % (MACOS_TO_DARWIN[introduced],))

if removed is not None:
+ removed_version = version.parse(removed)
+ if removed_version < sdk_version:
+ # nixpkgs hack: just skip things which don't match up with our SDK
+ continue
marker.append('platform_release<"%s"' % (MACOS_TO_DARWIN[removed],))

if marker:
49 changes: 30 additions & 19 deletions pkgs/os-specific/darwin/apple-sdk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ let
substArgs = lib.concatMap (x: [ "--subst-var-by" x deps'."${x}" ]) (lib.attrNames deps');
in lib.escapeShellArgs substArgs;

fixAndCheckReexports = name: deps: ''
# Fix and check tbd re-export references
find $out -name '*.tbd' | while read tbd; do
echo "Fixing re-exports in $tbd"
substituteInPlace "$tbd" ${mkFrameworkSubs name deps}

echo "Checking re-exports in $tbd"
print-reexports "$tbd" | while read target; do
local expected="''${target%.dylib}.tbd"
if ! [ -e "$expected" ]; then
echo -e "Re-export missing:\n\t$target\n\t(expected $expected)"
echo -e "While processing\n\t$tbd"
exit 1
else
echo "Re-exported target $target ok"
fi
done
done
'';

framework = name: deps: stdenv.mkDerivation {
name = "apple-framework-${name}";

Expand Down Expand Up @@ -146,23 +166,7 @@ let
cp -v "$tbd_source/$tbd" "$tbd_dest_dir"
done

# Fix and check tbd re-export references
find $out -name '*.tbd' | while read tbd; do
echo "Fixing re-exports in $tbd"
substituteInPlace "$tbd" ${mkFrameworkSubs name deps}

echo "Checking re-exports in $tbd"
print-reexports "$tbd" | while read target; do
local expected="''${target%.dylib}.tbd"
if ! [ -e "$expected" ]; then
echo -e "Re-export missing:\n\t$target\n\t(expected $expected)"
echo -e "While processing\n\t$tbd"
exit 1
else
echo "Re-exported target $target ok"
fi
done
done
${fixAndCheckReexports name deps}
'';

propagatedBuildInputs = builtins.attrValues deps;
Expand All @@ -185,14 +189,17 @@ let
};
};

tbdOnlyFramework = name: { private ? true }: stdenv.mkDerivation {
tbdOnlyFramework = name: { private ? true, deps ? {} }: stdenv.mkDerivation {
name = "apple-framework-${name}";
dontUnpack = true;
nativeBuildInputs = [ print-reexports ];
installPhase = ''
mkdir -p $out/Library/Frameworks/
cp -r ${darwin-stubs}/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework \
$out/Library/Frameworks
# NOTE there's no re-export checking here, this is probably wrong

${fixAndCheckReexports name deps}
'';
};
in rec {
Expand Down Expand Up @@ -312,7 +319,11 @@ in rec {
"Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy.tbd"
];
});
} // lib.genAttrs [ "ContactsPersistence" "UIFoundation" "GameCenter" ] (x: tbdOnlyFramework x {});

GameCenter = tbdOnlyFramework "GameCenter" {
deps = { inherit (frameworks) GameCenterFoundation GameCenterUI; };
};
} // lib.genAttrs [ "ContactsPersistence" "UIFoundation" "Network" "GameCenterFoundation" "GameCenterUI" ] (x: tbdOnlyFramework x {});

bareFrameworks = lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
Expand Down
15 changes: 14 additions & 1 deletion pkgs/os-specific/darwin/apple-sdk/frameworks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ with frameworks; with libs; {
Automator = {};
CFNetwork = {};
CalendarStore = {};
CloudKit = {};
Cocoa = { inherit AppKit CoreData; };
Collaboration = {};
Contacts = {};
ContactsUI = { inherit AppKit; };
# Impure version of CoreFoundation, this should not be used unless another
# framework includes headers that are not available in the pure version.
CoreFoundation = {};
Expand All @@ -38,6 +41,7 @@ with frameworks; with libs; {
CoreText = { inherit CoreGraphics; };
CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; };
CoreWLAN = { inherit SecurityFoundation; };
CryptoTokenKit = { inherit Foundation Security; };
DVDPlayback = {};
DirectoryService = {};
DiscRecording = { inherit libobjc CoreServices IOKit; };
Expand All @@ -46,6 +50,7 @@ with frameworks; with libs; {
EventKit = {};
ExceptionHandling = {};
FWAUserLib = {};
FinderSync = {};
ForceFeedback = { inherit IOKit; };
Foundation = { inherit libobjc CoreFoundation Security ApplicationServices SystemConfiguration; };
GLKit = {};
Expand All @@ -58,6 +63,7 @@ with frameworks; with libs; {
Hypervisor = {};
ICADevices = { inherit libobjc Carbon IOBluetooth; };
IMServicePlugIn = {};
Intents = {};
IOBluetoothUI = { inherit IOBluetooth; };
IOKit = {};
IOSurface = { inherit IOKit xpc; };
Expand All @@ -78,21 +84,28 @@ with frameworks; with libs; {
MapKit = {};
MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; };
MediaPlayer = {};
MediaLibrary = {};
MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; };
Metal = {};
MetalKit = { inherit ModelIO Metal; };
MultipeerConnectivity = { inherit Cocoa Foundation; };
ModelIO = {};
NetworkExtension = { inherit Foundation Network Security; };
NetFS = {};
NotificationCenter = {};
OSAKit = { inherit Carbon; };
OpenAL = {};
OpenCL = { inherit IOSurface OpenGL; };
OpenGL = {};
PCSC = { inherit CoreData; };
Photos = { inherit AVFoundation CoreGraphics CoreImage CoreLocation CoreMedia Foundation ImageIO; };
PhotosUI = { inherit AppKit Foundation MapKit Photos; };
PreferencePanes = {};
PubSub = {};
QTKit = { inherit CoreMediaIO CoreMedia MediaToolbox QuickTime VideoToolbox; };
QuickLook = { inherit ApplicationServices; };
SceneKit = {};
SafariServices = { };
SceneKit = { inherit GLKit; };
ScreenSaver = {};
Scripting = {};
ScriptingBridge = {};
Expand Down
5 changes: 4 additions & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6062,7 +6062,10 @@ in {
pynzb = callPackage ../development/python-modules/pynzb { };

pyobjc = if stdenv.isDarwin then
callPackage ../development/python-modules/pyobjc { }
callPackage ../development/python-modules/pyobjc {
inherit (pkgs.darwin.apple_sdk) frameworks;
inherit (pkgs.darwin) libdispatch libobjc;
}
else
throw "pyobjc can only be built on Mac OS";

Expand Down