1{
2 lib,
3 fetchurl,
4 fetchpatch,
5 buildPythonPackage,
6 python,
7 isPyPy,
8 pythonAtLeast,
9 pythonOlder,
10 sip-module ? "sip",
11 setuptools,
12}:
13
14buildPythonPackage rec {
15 pname = sip-module;
16 version = "4.19.25";
17 format = "other";
18
19 disabled = isPyPy;
20
21 src = fetchurl {
22 url = "https://www.riverbankcomputing.com/static/Downloads/sip/${version}/sip-${version}.tar.gz";
23 sha256 = "04a23cgsnx150xq86w1z44b6vr2zyazysy9mqax0fy346zlr77dk";
24 };
25
26 patches = lib.optionals (pythonAtLeast "3.11") [
27 (fetchpatch {
28 name = "sip-4-python3-11.patch";
29 url = "https://aur.archlinux.org/cgit/aur.git/plain/python3-11.patch?h=sip4&id=67b5907227e68845cdfafcf050fedb89ed653585";
30 sha256 = "sha256-cmuz2y5+T8EM/h03G2oboSnnOwrUjVKt2TUQaC9YAdE=";
31 })
32 ];
33
34 postPatch = lib.optionalString (pythonAtLeast "3.12") ''
35 substituteInPlace configure.py --replace-fail "from distutils" "from setuptools._distutils"
36 '';
37
38 propagatedBuildInputs = lib.optional (pythonAtLeast "3.12") setuptools;
39
40 configurePhase = ''
41 ${python.executable} ./configure.py \
42 --sip-module ${sip-module} \
43 -d $out/${python.sitePackages} \
44 -b $out/bin -e $out/include
45 '';
46
47 enableParallelBuilding = true;
48
49 pythonImportsCheck = [
50 # https://www.riverbankcomputing.com/pipermail/pyqt/2023-January/045094.html
51 # the import check for "sip" will fail, as it segfaults as the interpreter is shutting down.
52 # This is an upstream bug with sip4 on python3.12, and happens in the ubuntu packages version as well.
53 # As the package works fine until exit, just remove the import check for now.
54 # See discussion at https://github.com/NixOS/nixpkgs/pull/327976#discussion_r1706488319
55 (lib.optional (pythonOlder "3.12") sip-module)
56
57 "sipconfig"
58 ];
59
60 meta = with lib; {
61 description = "Creates C++ bindings for Python modules";
62 mainProgram = "sip";
63 homepage = "https://riverbankcomputing.com/";
64 license = licenses.gpl2Plus;
65 maintainers = with maintainers; [
66 lovek323
67 sander
68 ];
69 platforms = platforms.all;
70 };
71}