1{ lib
2, stdenv
3, python
4, fetchFromGitHub
5, cmake
6, Cocoa
7, fontconfig
8, freetype
9, libGL
10, libGLU
11, libX11
12, libXext
13, libXi
14, libXmu
15, opencascade-occt
16, rapidjson
17, swig4
18}:
19
20stdenv.mkDerivation rec {
21 pname = "pythonocc-core";
22 version = "7.6.2";
23
24 src = fetchFromGitHub {
25 owner = "tpaviot";
26 repo = "pythonocc-core";
27 rev = "refs/tags/${version}";
28 hash = "sha256-45pqPQ07KYlpFwJSAYVHbzuqDQTbAvPpxReal52DCzU=";
29 };
30
31 postPatch = ''
32 substituteInPlace CMakeLists.txt \
33 --replace "/usr/X11R6/lib/libGL.dylib" "${libGL}/lib/libGL.dylib" \
34 --replace "/usr/X11R6/lib/libGLU.dylib" "${libGLU}/lib/libGLU.dylib"
35 '';
36
37 nativeBuildInputs = [ cmake swig4 ];
38 buildInputs = [
39 python opencascade-occt
40 freetype libGL libGLU libX11 libXext libXmu libXi
41 fontconfig rapidjson
42 ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
43
44 cmakeFlags = [
45 "-Wno-dev"
46 "-DPYTHONOCC_INSTALL_DIRECTORY=${placeholder "out"}/${python.sitePackages}/OCC"
47 ];
48
49 passthru = {
50 # `python3Packages.pythonocc-core` must be updated in tandem with
51 # `opencascade-occt`, and including it in the bulk updates often breaks it.
52 skipBulkUpdate = true;
53 };
54
55 meta = with lib; {
56 description = "Python wrapper for the OpenCASCADE 3D modeling kernel";
57 homepage = "https://github.com/tpaviot/pythonocc-core";
58 changelog = "https://github.com/tpaviot/pythonocc-core/releases/tag/${version}";
59 license = licenses.lgpl3;
60 platforms = platforms.unix;
61 maintainers = with maintainers; [ gebner ];
62 };
63}