tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
gmsh: enable python bindings
Ben Gamari
3 years ago
34dd1761
4ed69ca0
+70
-2
3 changed files
expand all
collapse all
unified
split
pkgs
applications
science
math
gmsh
default.nix
fix-python.patch
top-level
python-packages.nix
+16
-2
pkgs/applications/science/math/gmsh/default.nix
···
1
{ lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
2
-
, zlib, libGL, libGLU, xorg, opencascade-occt }:
0
3
4
assert (!blas.isILP64) && (!lapack.isILP64);
0
5
6
stdenv.mkDerivation rec {
7
pname = "gmsh";
···
18
libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
19
xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
20
xorg.libICE
21
-
];
22
23
enableParallelBuilding = true;
24
0
0
0
0
0
0
25
# N.B. the shared object is used by bindings
26
cmakeFlags = [
27
"-DENABLE_BUILD_SHARED=ON"
···
30
];
31
32
nativeBuildInputs = [ cmake gfortran ];
0
0
0
0
0
0
33
34
doCheck = true;
35
···
1
{ lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
2
+
, zlib, libGL, libGLU, xorg, opencascade-occt
3
+
, python ? null, enablePython ? false }:
4
5
assert (!blas.isILP64) && (!lapack.isILP64);
6
+
assert enablePython -> (python != null);
7
8
stdenv.mkDerivation rec {
9
pname = "gmsh";
···
20
libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
21
xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
22
xorg.libICE
23
+
] ++ lib.optional enablePython python;
24
25
enableParallelBuilding = true;
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
+
33
# N.B. the shared object is used by bindings
34
cmakeFlags = [
35
"-DENABLE_BUILD_SHARED=ON"
···
38
];
39
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
+
'';
47
48
doCheck = true;
49
+50
pkgs/applications/science/math/gmsh/fix-python.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
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
3808
gmpy = callPackage ../development/python-modules/gmpy { };
3809
0
0
0
0
3810
gntp = callPackage ../development/python-modules/gntp { };
3811
3812
gnureadline = callPackage ../development/python-modules/gnureadline { };
···
3807
3808
gmpy = callPackage ../development/python-modules/gmpy { };
3809
3810
+
gmsh = toPythonModule (callPackage ../applications/science/math/gmsh {
3811
+
enablePython = true;
3812
+
});
3813
+
3814
gntp = callPackage ../development/python-modules/gntp { };
3815
3816
gnureadline = callPackage ../development/python-modules/gnureadline { };