Merge pull request #208396 from bgamari/wip/gmsh-shared
gmsh: Enable dynamic linking and Python bindings
This commit is contained in:
commit
e4c295a77d
3 changed files with 80 additions and 3 deletions
|
@ -1,15 +1,17 @@
|
|||
{ lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
|
||||
, zlib, libGL, libGLU, xorg, opencascade-occt }:
|
||||
, zlib, libGL, libGLU, xorg, opencascade-occt
|
||||
, python ? null, enablePython ? false }:
|
||||
|
||||
assert (!blas.isILP64) && (!lapack.isILP64);
|
||||
assert enablePython -> (python != null);
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gmsh";
|
||||
version = "4.11.0";
|
||||
version = "4.11.1";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://gmsh.info/src/gmsh-${version}-source.tgz";
|
||||
sha256 = "sha256-PPLyRFXuCSUsmeZNTmRilW5o8P8fN7rKC3jICdbMVXo=";
|
||||
sha256 = "sha256-xf4bfL1AOIioFJKfL9D11p4nYAIioYx4bbW3boAFs2U=";
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
|
@ -18,10 +20,31 @@ stdenv.mkDerivation rec {
|
|||
libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
|
||||
xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
|
||||
xorg.libICE
|
||||
] ++ lib.optional enablePython python;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
patches = [ ./fix-python.patch ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace api/gmsh.py --subst-var-by LIBPATH ${placeholder "out"}/lib/libgmsh.so
|
||||
'';
|
||||
|
||||
# N.B. the shared object is used by bindings
|
||||
cmakeFlags = [
|
||||
"-DENABLE_BUILD_SHARED=ON"
|
||||
"-DENABLE_BUILD_DYNAMIC=ON"
|
||||
"-DENABLE_OPENMP=ON"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake gfortran ];
|
||||
|
||||
postFixup = lib.optionalString enablePython ''
|
||||
mkdir -p $out/lib/python${python.pythonVersion}/site-packages
|
||||
mv $out/lib/gmsh.py $out/lib/python${python.pythonVersion}/site-packages
|
||||
mv $out/lib/*.dist-info $out/lib/python${python.pythonVersion}/site-packages
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
|
||||
meta = {
|
||||
|
|
50
pkgs/applications/science/math/gmsh/fix-python.patch
Normal file
50
pkgs/applications/science/math/gmsh/fix-python.patch
Normal file
|
@ -0,0 +1,50 @@
|
|||
diff --git a/api/gmsh.py b/api/gmsh.py
|
||||
index 747acb203..02004da5d 100644
|
||||
--- a/api/gmsh.py
|
||||
+++ b/api/gmsh.py
|
||||
@@ -44,44 +44,7 @@ moduledir = os.path.dirname(os.path.realpath(__file__))
|
||||
parentdir1 = os.path.dirname(moduledir)
|
||||
parentdir2 = os.path.dirname(parentdir1)
|
||||
|
||||
-if platform.system() == "Windows":
|
||||
- libname = "gmsh-4.11.dll"
|
||||
-elif platform.system() == "Darwin":
|
||||
- libname = "libgmsh.4.11.dylib"
|
||||
-else:
|
||||
- libname = "libgmsh.so.4.11"
|
||||
-
|
||||
-# check if the library is in the same directory as the module...
|
||||
-libpath = os.path.join(moduledir, libname)
|
||||
-
|
||||
-# ... or in the parent directory or its lib or Lib subdirectory
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir1, libname)
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir1, "lib", libname)
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir1, "Lib", libname)
|
||||
-
|
||||
-# ... or in the parent of the parent directory or its lib or Lib subdirectory
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir2, libname)
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir2, "lib", libname)
|
||||
-if not os.path.exists(libpath):
|
||||
- libpath = os.path.join(parentdir2, "Lib", libname)
|
||||
-
|
||||
-# if we couldn't find it, use ctype's find_library utility...
|
||||
-if not os.path.exists(libpath):
|
||||
- if platform.system() == "Windows":
|
||||
- libpath = find_library("gmsh-4.11")
|
||||
- if not libpath:
|
||||
- libpath = find_library("gmsh")
|
||||
- else:
|
||||
- libpath = find_library("gmsh")
|
||||
-
|
||||
-# ... and print a warning if everything failed
|
||||
-if not os.path.exists(libpath):
|
||||
- print("Warning: could not find Gmsh shared library " + libname)
|
||||
+libpath = "@LIBPATH@"
|
||||
|
||||
lib = CDLL(libpath)
|
||||
|
|
@ -3811,6 +3811,10 @@ self: super: with self; {
|
|||
|
||||
gmpy = callPackage ../development/python-modules/gmpy { };
|
||||
|
||||
gmsh = toPythonModule (callPackage ../applications/science/math/gmsh {
|
||||
enablePython = true;
|
||||
});
|
||||
|
||||
gntp = callPackage ../development/python-modules/gntp { };
|
||||
|
||||
gnureadline = callPackage ../development/python-modules/gnureadline { };
|
||||
|
|
Loading…
Reference in a new issue