Commit bec28326 authored by Dave DeMarle's avatar Dave DeMarle

Make the python module installation directory configurable.

Advanced cache variable VTK_INSTALL_PYTHON_MODULE_DIR now controls
where the install target puts the python .py files and corresponding
python extension libraries (*Python.so or *Python.dll). ThirdParty
modules like Zope, Twisted and Autobahn should be placed there,
vtk extensions should go inside the vtk directory there.

System installers for instance will likely want to set it to be:
/usr/local/lib/pythonX.Y/site-packages #Linux
/Library/Python/X.Y/site-packages #Mac
C:/PythonXY/Lib/site-packages #Windows

ParaView will use it to put the VTK python modules underneath its own.
Also for ParaView's use, there is once again a way to disable installation
of the vtkpython binary. Now it is done by setting VTK_INSTALL_NO_PYTHON_EXES.

The change also updates the README.txt per VTK 6.X layout and
removes references to setup.py, which we no longer support.

Change-Id: I92c1d65c8ca8aa44ca2d54cc4526bbc72f42eb0d
parent 8dd9dfaa
......@@ -114,6 +114,11 @@ endif()
if(NOT VTK_WWW_DIR)
set(VTK_WWW_DIR "${VTK_BINARY_DIR}/www")
endif()
if(NOT VTK_INSTALL_PYTHON_MODULE_DIR)
set (VTK_INSTALL_PYTHON_MODULE_DIR "-NOTFOUND" CACHE
PATH "Directory where python modules will be installed")
mark_as_advanced(VTK_INSTALL_PYTHON_MODULE_DIR)
endif()
if (CMAKE_CROSSCOMPILING AND NOT COMPILE_TOOLS_IMPORTED)
# if CMAKE_CROSSCOMPILING is true, we need to import build-tools targets.
......
......@@ -11,7 +11,6 @@ if(NOT VTK_USE_SYSTEM_AUTOBAHN)
# Extract path where python module should be copied
get_property(pymodule_build_dir GLOBAL PROPERTY VTK_PYMODULE_BUILD_DIR)
get_property(pymodule_install_dir GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR)
set(AutobahnPython_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/autobahn")
set(AutobahnPython_BINARY_DIR "${pymodule_build_dir}/autobahn")
......@@ -19,9 +18,7 @@ if(NOT VTK_USE_SYSTEM_AUTOBAHN)
build_python_package("AutobahnPython" ${AutobahnPython_SOURCE_DIR}
${AutobahnPython_BINARY_DIR})
if(NOT VTK_INSTALL_NO_PYTHON)
install(DIRECTORY ${AutobahnPython_BINARY_DIR}
DESTINATION "${pymodule_install_dir}"
COMPONENT Runtime)
endif()
install(DIRECTORY ${AutobahnPython_BINARY_DIR}
DESTINATION "${VTK_INSTALL_PYTHON_MODULE_DIR}"
COMPONENT Runtime)
endif()
......@@ -11,16 +11,13 @@ if(NOT VTK_USE_SYSTEM_TWISTED)
# Extract path where python module should be copied
get_property(pymodule_build_dir GLOBAL PROPERTY VTK_PYMODULE_BUILD_DIR)
get_property(pymodule_install_dir GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR)
set(Twisted_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/twisted")
set(Twisted_BINARY_DIR "${pymodule_build_dir}/twisted")
build_python_package("Twisted" ${Twisted_SOURCE_DIR} ${Twisted_BINARY_DIR})
if(NOT VTK_INSTALL_NO_PYTHON)
install(DIRECTORY ${Twisted_BINARY_DIR}
DESTINATION "${pymodule_install_dir}"
COMPONENT Runtime)
endif()
install(DIRECTORY ${Twisted_BINARY_DIR}
DESTINATION "${VTK_INSTALL_PYTHON_MODULE_DIR}"
COMPONENT Runtime)
endif()
......@@ -11,16 +11,13 @@ if(NOT VTK_USE_SYSTEM_ZOPE)
# Extract path where python module should be copied
get_property(pymodule_build_dir GLOBAL PROPERTY VTK_PYMODULE_BUILD_DIR)
get_property(pymodule_install_dir GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR)
set(zope_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zope")
set(zope_BINARY_DIR "${pymodule_build_dir}/zope")
build_python_package("zope" ${zope_SOURCE_DIR} ${zope_BINARY_DIR})
if(NOT VTK_INSTALL_NO_PYTHON)
install(DIRECTORY ${zope_BINARY_DIR}
DESTINATION "${pymodule_install_dir}"
COMPONENT Runtime)
endif()
install(DIRECTORY ${zope_BINARY_DIR}
DESTINATION "${VTK_INSTALL_PYTHON_MODULE_DIR}"
COMPONENT Runtime)
endif()
......@@ -26,7 +26,11 @@ endif()
# Export location of python module dirs in install and build tree for every vtkpython module to use
# As long as those modules depend on vtkpython, they can retrieve and use these
set_property(GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR
"${VTK_INSTALL_LIBRARY_DIR}/python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}/site-packages")
if (NOT VTK_INSTALL_PYTHON_MODULE_DIR)
set(VTK_INSTALL_PYTHON_MODULE_DIR
"${VTK_INSTALL_LIBRARY_DIR}/python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}/site-packages"
CACHE
PATH "Directory where python modules will be installed" FORCE)
endif()
set_property(GLOBAL PROPERTY VTK_PYMODULE_BUILD_DIR
"${VTK_BINARY_DIR}/Wrapping/Python/")
......@@ -7,7 +7,6 @@ include(vtkPythonPackages)
# Extract path where python module should be copied
get_property(pymodule_build_dir GLOBAL PROPERTY VTK_PYMODULE_BUILD_DIR)
get_property(pymodule_install_dir GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR)
set(vtkWebPython_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(vtkWebPython_BINARY_DIR "${pymodule_build_dir}/vtk/web")
......@@ -20,8 +19,6 @@ if(NOT VTK_WRAP_PYTHON)
message(FATAL_ERROR "Web group can NOT work if VTK_WRAP_PYTHON is not ON.")
endif()
if(NOT VTK_INSTALL_NO_PYTHON)
install(DIRECTORY ${vtkWebPython_BINARY_DIR}
DESTINATION "${pymodule_install_dir}"
COMPONENT Runtime)
endif()
\ No newline at end of file
install(DIRECTORY ${vtkWebPython_BINARY_DIR}
DESTINATION "${VTK_INSTALL_PYTHON_MODULE_DIR}/vtk"
COMPONENT Runtime)
......@@ -268,38 +268,38 @@ if(PYTHON_EXECUTABLE)
${vtkpython_pyc_depends})
# If no runtime is to be installed then do not install python modules.
if(VTK_INSTALL_NO_RUNTIME)
set(VTK_INSTALL_NO_PYTHON 1)
endif()
if(NOT VTK_INSTALL_NO_RUNTIME)
if (NOT VTK_INSTALL_NO_PYTHON)
get_property(pymodule_instdir GLOBAL PROPERTY VTK_PYMODULE_INSTALL_DIR)
# Install python modules (.py and *.pyd)
# Install python modules
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/vtk"
DESTINATION ${pymodule_instdir} COMPONENT RuntimeLibraries
DESTINATION ${VTK_INSTALL_PYTHON_MODULE_DIR} COMPONENT RuntimeLibraries
USE_SOURCE_PERMISSIONS)
# Install python extension library behind the modules (.dll,.lib,.so)
# Install python extension library that backs the modules
if (BUILD_SHARED_LIBS AND NOT VTK_INSTALL_NO_LIBRARIES)
foreach(module ${VTK_PYTHON_MODULES})
install(TARGETS ${module}Python
EXPORT ${VTK_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${VTK_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${pymodule_instdir}/vtk COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${VTK_INSTALL_PYTHON_MODULE_DIR}/vtk COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${VTK_INSTALL_ARCHIVE_DIR} COMPONENT Development
)
endforeach()
endif()
# Install the vtkpython executable
install(TARGETS vtkpython ${VTKPYTHON_EXECUTABLE}
DESTINATION ${VTK_INSTALL_RUNTIME_DIR})
if(PVTKPYTHON_EXECUTABLE)
# Install the mpi enabled vtkpython executable
install(TARGETS pvtkpython ${PVTKPYTHON_EXECUTABLE}
# Install the conveniently configured python interpretters
if(NOT VTK_INSTALL_NO_PYTHON_EXES)
# Install the vtkpython executable
install(TARGETS vtkpython
DESTINATION ${VTK_INSTALL_RUNTIME_DIR})
if(PVTKPYTHON_EXECUTABLE)
# Install the mpi enabled vtkpython executable
install(TARGETS pvtkpython
DESTINATION ${VTK_INSTALL_RUNTIME_DIR})
endif()
endif()
endif()
endif()
# Configured file and directory locations.
SET(PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
SET(VTK_BINARY_DIR "@VTK_BINARY_DIR@")
# Convert the prefix to a windows path if necessary. The python
# distutils implementation seems sensitive to the slash direction.
IF(WIN32)
IF(NOT CYGWIN)
STRING(REGEX REPLACE "/" "\\\\" CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}")
ENDIF(NOT CYGWIN)
ENDIF(WIN32)
# Run python on setup.py to install the python modules.
EXEC_PROGRAM("${PYTHON_EXECUTABLE}" "${VTK_BINARY_DIR}/Wrapping/Python" ARGS
"setup.py" "install" @VTK_PYTHON_SETUP_BUILD_TYPE@ @VTK_PYTHON_SETUP_ARGS@
)
......@@ -44,7 +44,7 @@ modules.
(2) Using the package from the source build without installing it
system wide and without using `vtkpython`. This is most
useful when you build VTK off a CVS checkout and do not want
useful when you build VTK off a git clone and do not want
to install it system wide and still want to use the vanilla
Python interpreter. This is also useful if you are not the
administrator of the machine you are using/building VTK on.
......@@ -82,25 +82,17 @@ ${VTK_ROOT}/Wrapping/Python:${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
RelWithDebInfo.
(3) Installation via distutils to a directory different from the
(3) Installation via to a directory different from the
`VTK_ROOT` directory. To install VTK built from source you
simply need to run the "install rule". Under Unix this
implies running `make install` and under Windows this implies
running the INSTALL target.
The installation rule internally executes the
``VTK_BINARY_DIR/Wrapping/Python/setup.py`` script.
`setup.py` is a distutils script that should install
VTK-Python correctly. The `setup.py` script may also be
executed from the `VTK_BINARY_DIR` in order to build an
installer (via `bdist_wininst`) or to build a Python Egg.
VTK-Python interpreters
^^^^^^^^^^^^^^^^^^^^^^^
In order to solve some problems with running VTK-Python on some
platforms and compilers a special Python interpreter is distributed
platforms and compilers a Python interpreter is distributed
along with VTK. This new interpreter is called `vtkpython` and is
the recommended way of running VTK-Python scripts. If the vanilla
Python interpreter is good enough and works well for you, please use
......@@ -128,71 +120,19 @@ users will just do::
# or
from vtk import *
and all the available 'kits' will be loaded - just like with the
older vtkpython. The name of the kits is available in the kits
variable::
import vtk
print vtk.kits
['common', 'filtering', 'io', ...]
and all the available 'modules' will be loaded - just like with the
older vtkpython.
If the user specifically wants just the classes the Common directory
If the user specifically wants just the classes the Common/Core module
imported the user does::
import vtk.common
import vtk.vtkCommonCore
All the kit names are in lowercase. This is similar to the way in
which the Tcl packages are split. Similarly, classes specifically
in other kits can be imported by using the appropriate kit name.
Please do note that even when you import vtk.common, the vtk
Please do note that even when you import vtk.vtkCommonCore, the vtk
namespace will still have all the kits loaded inside it. Its just
that vtk.common will have only the classes from the Common
that vtk.vtkCommonCore will have only the classes from the Common/Core
directory.
Valid Kit names
~~~~~~~~~~~~~~~
Required Kits
-------------
common, filtering, io, imaging and graphics.
These are the required kits that you must have to use VTK. You
can import all of them using the required module like so:
from vtk.required import *
You should have all the required kits in your namespace. If any
of them is not importable you *will* get an ImportError.
Optional Kits
-------------
genericfiltering, hybrid, parallel, rendering, volumerendering,
and widgets.
These are the optional kits. Unlike the Tcl packages importing
these kits *will not* import all the required kits in as well.
For the rationale behind this please read this mail and also the
thread here:
http://public.kitware.com/pipermail/vtk-developers/2001-October/000828.html
If you don't have a particular optional kit then Python will not
raise an exception when importing vtk, but if you try loading it
directly like so::
import vtk.parallel
Then you will receive an import error if there was one. Also, if
the module exists but there are linking errors you will get a
LinkError exception.
Other VTK related modules
^^^^^^^^^^^^^^^^^^^^^^^^^
Apart from the basic VTK functionality there are other useful VTK
related modules in the package. There are various widgets for
different GUI toolkits. These are available in the various
......@@ -228,16 +168,6 @@ There is also a `vtk.test` package that allows one to create unit
tests for VTK-Python.
Backwards compatibility
^^^^^^^^^^^^^^^^^^^^^^^
Since VTK-4.0, the usage of `vtkpython`, `vtkpythontk`,
`vtkTkRenderWidget` and other modules in the Wrapping/Python
directory were deprecated. As of VTK-5.0, these files are no longer
available. Please use the `vtk` package instead which provides the
functionality.
Writing and running VTK-Python tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -287,22 +217,15 @@ in the form of Debian, RPM and other packages.
files should be installed somewhere in the linkers path (for
example in `\usr\lib`). Under Windows these should be installed
in a directory that is in the `PATH`. The Python extension modules
should be installed via the `setup.py` file inside the `vtk`
package. Typically these should be installed to
should are typically installed to
`/usr/lib/pythonX.Y/site-packages/vtk` (or
`PythonX.Y\Lib\site-packages\vtk`).
The VTK install rule (`make install` under Unix) will usually do the
right thing in installing everything. Make sure that the
`CMAKE_INSTALL_PREFIX` variable is set appropriately. There are two
ways to customize python module installation. First, one may modify
the VTK_PYTHON_SETUP_ARGS CMake cache variable to set the options
passed to the setup.py script. The default value for this variable
provides reasonable behavior for packagers. Second, one may
define VTK_INSTALL_NO_PYTHON:BOOL=ON in the CMake cache which will
disable the automatic execution of setup.py as part of the install
process. Then one may run ``python setup.py install`` manually
with the desired options.
`CMAKE_INSTALL_PREFIX` variable is set appropriately. You may modify
the VTK_INSTALL_PYTHON_MODULE_DIR CMake cache variable to change the
installation location for the Python extenson modules.
Common problems
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment