vtk: Generate egg-info

VTK's cmake build system fails to generate an `.egg-info` file, which
various libraries in the Python package system (e.g. `pkg_resources`)
would use to identify the package. Work around this by generating an
`egg-info` file ourselves.

This will allow us to drop a workaround in `mayavi`.
This commit is contained in:
Ben Gamari 2022-12-31 11:07:23 -05:00
parent 4769274f53
commit 06ca784b25
3 changed files with 15 additions and 4 deletions

View file

@ -2,7 +2,7 @@
{ stdenv, lib, fetchurl, cmake, libGLU, libGL, libX11, xorgproto, libXt, libpng, libtiff
, fetchpatch
, enableQt ? false, qtbase, qtx11extras, qttools, qtdeclarative, qtEnv
, enablePython ? false, pythonInterpreter ? throw "vtk: Python support requested, but no python interpreter was given."
, enablePython ? false, python ? throw "vtk: Python support requested, but no python interpreter was given."
# Darwin support
, Cocoa, CoreServices, DiskArbitration, IOKit, CFNetwork, Security, GLUT, OpenGL
, ApplicationServices, CoreText, IOSurface, ImageIO, xpc, libobjc
@ -11,7 +11,7 @@
let
inherit (lib) optionalString optionals optional;
pythonMajor = lib.substring 0 1 pythonInterpreter.pythonVersion;
pythonMajor = lib.substring 0 1 python.pythonVersion;
in stdenv.mkDerivation rec {
pname = "vtk${optionalString enableQt "-qvtk"}";
@ -47,7 +47,7 @@ in stdenv.mkDerivation rec {
OpenGL
GLUT
] ++ optionals enablePython [
pythonInterpreter
python
];
propagatedBuildInputs = optionals stdenv.isDarwin [ libobjc ]
++ optionals stdenv.isLinux [ libX11 libGL ];
@ -89,6 +89,13 @@ in stdenv.mkDerivation rec {
sed -i 's/fprintf(output, shift)/fprintf(output, "%s", shift)/g' ./ThirdParty/libxml2/vtklibxml2/xpath.c
'';
postInstall = optionalString enablePython ''
substitute \
${./vtk.egg-info} \
$out/lib/python${python.pythonVersion}/site-packages/vtk-${version}.egg-info \
--subst-var-by VTK_VER "${version}"
'';
meta = with lib; {
description = "Open source libraries for 3D computer graphics, image processing and visualization";
homepage = "https://www.vtk.org/";

View file

@ -0,0 +1,4 @@
Metadata-Version: 2.1
Version: @VTK_VER@
Summary: VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization
Platform: UNKNOWN

View file

@ -11905,7 +11905,7 @@ self: super: with self; {
vt-py = callPackage ../development/python-modules/vt-py { };
vtk = toPythonModule (pkgs.vtk_9.override {
pythonInterpreter = python;
inherit python;
enablePython = true;
});