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