Skip to content

Commit 6e41e85

Browse files
committed
Build osmesa properly
1 parent 4a8ad37 commit 6e41e85

3 files changed

Lines changed: 63 additions & 8 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ if(VTKPythonPackage_SUPERBUILD)
5151
# re-using existing resources.
5252
#
5353
# VTK_SOURCE_DIR: Path to an existing source directory
54+
# VTK_Group_Web: Whether web package should be included
55+
# VTK_OPENGL_HAS_OSMESA: Whether to use OSMesa for offscreen rendering
5456
#
5557

5658
option(VTKPythonPackage_BUILD_PYTHON "Build VTK python module" ON)
@@ -59,6 +61,13 @@ if(VTKPythonPackage_SUPERBUILD)
5961
option(VTK_Group_Web "Build VTK web module" OFF)
6062
mark_as_advanced(VTK_Group_Web)
6163

64+
option(VTK_OPENGL_HAS_OSMESA "Use OSMesa for offscreen rendering" OFF)
65+
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)
66+
if(VTK_OPENGL_HAS_OSMESA)
67+
set(NOT_VTK_OPENGL_HAS_OSMESA OFF)
68+
else()
69+
set(NOT_VTK_OPENGL_HAS_OSMESA ON)
70+
endif()
6271

6372
#-----------------------------------------------------------------------------
6473
include(ExternalProject)
@@ -203,6 +212,8 @@ if(VTKPythonPackage_SUPERBUILD)
203212
# Rendering options
204213
-DVTK_Group_Qt:BOOL=OFF # XXX Enabled this later
205214
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
215+
-DVTK_OPENGL_HAS_OSMESA:BOOL=${VTK_OPENGL_HAS_OSMESA}
216+
-DVTK_USE_X:BOOL=${NOT_VTK_OPENGL_HAS_OSMESA}
206217

207218
# Module options
208219
-DVTK_Group_Web:BOOL=${VTK_Group_Web}

‎Dockerfile‎

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
11
FROM python:3.6
22
MAINTAINER Zach Mullen <zach.mullen@kitware.com>
33

4-
RUN apt-get update && apt-get install -y libglapi-mesa libosmesa6 freeglut3-dev && \
5-
pip install cmake ninja scikit-build
4+
RUN pip install cmake ninja scikit-build
65

6+
# Download llvm
7+
RUN wget http://releases.llvm.org/3.9.1/llvm-3.9.1.src.tar.xz && \
8+
tar xf llvm-3.9.1.src.tar.xz && rm llvm-3.9.1.src.tar.xz
9+
10+
# Build llvm
11+
RUN cd /llvm-3.9.1.src && mkdir _build && cd _build && \
12+
cmake \
13+
-DCMAKE_BUILD_TYPE=Release \
14+
-DLLVM_BUILD_LLVM_DYLIB=ON \
15+
-DLLVM_ENABLE_RTTI=ON \
16+
-DLLVM_INSTALL_UTILS=ON \
17+
-DLLVM_TARGETS_TO_BUILD:STRING=X86 \
18+
.. && make -j4 && make install
19+
20+
# Download osmesa
21+
RUN wget https://mesa.freedesktop.org/archive/mesa-17.2.4.tar.xz && \
22+
tar xf mesa-17.2.4.tar.xz && rm mesa-17.2.4.tar.xz
23+
24+
# Build osmesa
25+
RUN cd /mesa-17.2.4 && ./configure \
26+
--disable-xvmc \
27+
--disable-glx \
28+
--disable-dri \
29+
--disable-gbm \
30+
--with-dri-drivers= \
31+
--with-gallium-drivers=swrast \
32+
--enable-texture-float \
33+
--disable-egl \
34+
--with-platforms= \
35+
--enable-gallium-osmesa \
36+
--enable-llvm && \
37+
make -j4 && make install
38+
39+
# Build VTK with python
740
COPY . /VTKPythonPackage
841

9-
RUN cd VTKPythonPackage && \
10-
VTK_CMAKE_ARGS="-DVTK_Group_Web:BOOL=ON" python setup.py bdist_wheel
11-
RUN pip install /VTKPythonPackage/dist/vtk-*.whl
42+
RUN cd /VTKPythonPackage && \
43+
VTK_CMAKE_ARGS="-DVTK_OPENGL_HAS_OSMESA:BOOL=ON -DVTK_Group_Web:BOOL=ON" python setup.py bdist_wheel
44+
RUN pip install /VTKPythonPackage/dist/vtk-*.whl && \
45+
ldconfig && \
46+
rm -rf /VTKPythonPackage && rm -rf /mesa-17.2.4 && rm -rf /llvm-3.9.1.src

‎setup.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@
2727
py_modules=[
2828
'vtkVersion',
2929
],
30-
download_url=r'http://www.vtk.org/download/',
31-
description=r'VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization',
32-
long_description='VTK is an open-source, cross-platform library that provides developers with an extensive suite of software tools for 3D computer graphics, image processing, and visualization. It consists of a C++ class library and several interpreted interface layers including Tcl/Tk, Java, and Python. VTK supports a wide variety of visualization algorithms including scalar, vector, tensor, texture, and volumetric methods, as well as advanced modeling techniques such as implicit modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation. VTK has an extensive information visualization framework and a suite of 3D interaction widgets. The toolkit supports parallel processing and integrates with various databases on GUI toolkits such as Qt and Tk.',
30+
download_url='http://www.vtk.org/download/',
31+
description='VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization',
32+
long_description='VTK is an open-source, cross-platform library that provides developers with '
33+
'an extensive suite of software tools for 3D computer graphics, image processing,'
34+
'and visualization. It consists of a C++ class library and several interpreted interface '
35+
'layers including Tcl/Tk, Java, and Python. VTK supports a wide variety of visualization '
36+
'algorithms including scalar, vector, tensor, texture, and volumetric methods, as well as '
37+
'advanced modeling techniques such as implicit modeling, polygon reduction, mesh '
38+
'smoothing, cutting, contouring, and Delaunay triangulation. VTK has an extensive '
39+
'information visualization framework and a suite of 3D interaction widgets. The toolkit '
40+
'supports parallel processing and integrates with various databases on GUI toolkits such '
41+
'as Qt and Tk.',
3342
classifiers=[
3443
"License :: OSI Approved :: BSD License",
3544
"Programming Language :: Python",

0 commit comments

Comments
 (0)