1{
2 buildPythonPackage,
3 darwin,
4 fetchFromGitHub,
5 lib,
6 setuptools,
7}:
8
9buildPythonPackage rec {
10 pname = "pyobjc-core";
11 version = "11.0";
12 pyproject = true;
13
14 src = fetchFromGitHub {
15 owner = "ronaldoussoren";
16 repo = "pyobjc";
17 tag = "v${version}";
18 hash = "sha256-RhB0Ht6vyDxYwDGS+A9HZL9ySIjWlhdB4S+gHxvQQBg=";
19 };
20
21 sourceRoot = "source/pyobjc-core";
22
23 build-system = [ setuptools ];
24
25 buildInputs = [
26 darwin.DarwinTools
27 darwin.libffi
28 ];
29
30 nativeBuildInputs = [
31 darwin.DarwinTools # sw_vers
32 ];
33
34 # See https://github.com/ronaldoussoren/pyobjc/pull/641. Unfortunately, we
35 # cannot just pull that diff with fetchpatch due to https://discourse.nixos.org/t/how-to-apply-patches-with-sourceroot/59727.
36 postPatch = ''
37 for file in Modules/objc/test/*.m; do
38 substituteInPlace "$file" --replace "[[clang::suppress]]" ""
39 done
40
41 substituteInPlace setup.py \
42 --replace-fail "-buildversion" "-buildVersion" \
43 --replace-fail "-productversion" "-productVersion"
44 '';
45
46 env.NIX_CFLAGS_COMPILE = toString [
47 "-I${darwin.libffi.dev}/include"
48 "-Wno-error=cast-function-type-mismatch"
49 "-Wno-error=unused-command-line-argument"
50 ];
51
52 pythonImportsCheck = [ "objc" ];
53
54 meta = with lib; {
55 description = "Python <-> Objective-C bridge";
56 homepage = "https://github.com/ronaldoussoren/pyobjc";
57 license = licenses.mit;
58 platforms = platforms.darwin;
59 maintainers = with maintainers; [ samuela ];
60 };
61}