gmsh: enable python bindings

+70 -2
+16 -2
pkgs/applications/science/math/gmsh/default.nix
··· 1 1 { lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg 2 - , zlib, libGL, libGLU, xorg, opencascade-occt }: 2 + , zlib, libGL, libGLU, xorg, opencascade-occt 3 + , python ? null, enablePython ? false }: 3 4 4 5 assert (!blas.isILP64) && (!lapack.isILP64); 6 + assert enablePython -> (python != null); 5 7 6 8 stdenv.mkDerivation rec { 7 9 pname = "gmsh"; ··· 18 20 libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes 19 21 xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM 20 22 xorg.libICE 21 - ]; 23 + ] ++ lib.optional enablePython python; 22 24 23 25 enableParallelBuilding = true; 24 26 27 + patches = [ ./fix-python.patch ]; 28 + 29 + postPatch = '' 30 + substituteInPlace api/gmsh.py --subst-var-by LIBPATH ${placeholder "out"}/lib/libgmsh.so 31 + ''; 32 + 25 33 # N.B. the shared object is used by bindings 26 34 cmakeFlags = [ 27 35 "-DENABLE_BUILD_SHARED=ON" ··· 30 38 ]; 31 39 32 40 nativeBuildInputs = [ cmake gfortran ]; 41 + 42 + postFixup = lib.optionalString enablePython '' 43 + mkdir -p $out/lib/python${python.pythonVersion}/site-packages 44 + mv $out/lib/gmsh.py $out/lib/python${python.pythonVersion}/site-packages 45 + mv $out/lib/*.dist-info $out/lib/python${python.pythonVersion}/site-packages 46 + ''; 33 47 34 48 doCheck = true; 35 49
+50
pkgs/applications/science/math/gmsh/fix-python.patch
··· 1 + diff --git a/api/gmsh.py b/api/gmsh.py 2 + index 747acb203..02004da5d 100644 3 + --- a/api/gmsh.py 4 + +++ b/api/gmsh.py 5 + @@ -44,44 +44,7 @@ moduledir = os.path.dirname(os.path.realpath(__file__)) 6 + parentdir1 = os.path.dirname(moduledir) 7 + parentdir2 = os.path.dirname(parentdir1) 8 + 9 + -if platform.system() == "Windows": 10 + - libname = "gmsh-4.11.dll" 11 + -elif platform.system() == "Darwin": 12 + - libname = "libgmsh.4.11.dylib" 13 + -else: 14 + - libname = "libgmsh.so.4.11" 15 + - 16 + -# check if the library is in the same directory as the module... 17 + -libpath = os.path.join(moduledir, libname) 18 + - 19 + -# ... or in the parent directory or its lib or Lib subdirectory 20 + -if not os.path.exists(libpath): 21 + - libpath = os.path.join(parentdir1, libname) 22 + -if not os.path.exists(libpath): 23 + - libpath = os.path.join(parentdir1, "lib", libname) 24 + -if not os.path.exists(libpath): 25 + - libpath = os.path.join(parentdir1, "Lib", libname) 26 + - 27 + -# ... or in the parent of the parent directory or its lib or Lib subdirectory 28 + -if not os.path.exists(libpath): 29 + - libpath = os.path.join(parentdir2, libname) 30 + -if not os.path.exists(libpath): 31 + - libpath = os.path.join(parentdir2, "lib", libname) 32 + -if not os.path.exists(libpath): 33 + - libpath = os.path.join(parentdir2, "Lib", libname) 34 + - 35 + -# if we couldn't find it, use ctype's find_library utility... 36 + -if not os.path.exists(libpath): 37 + - if platform.system() == "Windows": 38 + - libpath = find_library("gmsh-4.11") 39 + - if not libpath: 40 + - libpath = find_library("gmsh") 41 + - else: 42 + - libpath = find_library("gmsh") 43 + - 44 + -# ... and print a warning if everything failed 45 + -if not os.path.exists(libpath): 46 + - print("Warning: could not find Gmsh shared library " + libname) 47 + +libpath = "@LIBPATH@" 48 + 49 + lib = CDLL(libpath) 50 +
+4
pkgs/top-level/python-packages.nix
··· 3807 3807 3808 3808 gmpy = callPackage ../development/python-modules/gmpy { }; 3809 3809 3810 + gmsh = toPythonModule (callPackage ../applications/science/math/gmsh { 3811 + enablePython = true; 3812 + }); 3813 + 3810 3814 gntp = callPackage ../development/python-modules/gntp { }; 3811 3815 3812 3816 gnureadline = callPackage ../development/python-modules/gnureadline { };