Commit 5b557af6 authored by Brad King's avatar Brad King 💬
Browse files

ENH: Updated setup.py script to fully support installation both with and...

ENH: Updated setup.py script to fully support installation both with and without configuration types in the build tree.  The exact set of libraries to install is now computed so that if one does not exist an error is reported.
parent 55622264
# Create a setup.py file.
CONFIGURE_FILE(${VTK_SOURCE_DIR}/Wrapping/Python/setup.py.in
${VTK_BINARY_DIR}/Wrapping/Python/setup.py)
# create the VTK/Python executable
CONFIGURE_FILE(${VTK_SOURCE_DIR}/Wrapping/Python/vtkPythonAppInitConfigure.h.in
${VTK_BINARY_DIR}/Wrapping/Python/vtkPythonAppInitConfigure.h)
......@@ -293,6 +289,40 @@ IF(PYTHON_EXECUTABLE)
${vtkpython_pyc_depends})
ENDIF(PYTHON_EXECUTABLE)
# Create the setup.py file.
IF(CMAKE_CONFIGURATION_TYPES)
# The build has multiple configuration types. If CMAKE_BUILD_TYPE
# is set use it as the default BUILD_TYPE for setup.py to install.
SET(VTK_PYTHON_HAS_CONFIG_TYPES 1)
IF(CMAKE_BUILD_TYPE)
SET(VTK_PYTHON_BUILD_TYPE "\"${CMAKE_BUILD_TYPE}\"")
ELSE(CMAKE_BUILD_TYPE)
SET(VTK_PYTHON_BUILD_TYPE "[]")
ENDIF(CMAKE_BUILD_TYPE)
ELSE(CMAKE_CONFIGURATION_TYPES)
# The build has one configuration type. The build type does not
# affect installation.
SET(VTK_PYTHON_HAS_CONFIG_TYPES 0)
SET(VTK_PYTHON_BUILD_TYPE "[]")
ENDIF(CMAKE_CONFIGURATION_TYPES)
IF(VTK_USE_RENDERING)
SET(VTK_PYTHON_USE_RENDERING 1)
ELSE(VTK_USE_RENDERING)
SET(VTK_PYTHON_USE_RENDERING 0)
ENDIF(VTK_USE_RENDERING)
IF(VTK_USE_PARALLEL)
SET(VTK_PYTHON_USE_PARALLEL 1)
ELSE(VTK_USE_PARALLEL)
SET(VTK_PYTHON_USE_PARALLEL 0)
ENDIF(VTK_USE_PARALLEL)
IF(VTK_USE_MPI)
SET(VTK_PYTHON_USE_MPI 1)
ELSE(VTK_USE_MPI)
SET(VTK_PYTHON_USE_MPI 0)
ENDIF(VTK_USE_MPI)
CONFIGURE_FILE(${VTK_SOURCE_DIR}/Wrapping/Python/setup.py.in
${VTK_BINARY_DIR}/Wrapping/Python/setup.py @ONLY IMMEDIATE)
# Allow the user to customize their build with some local options
#
INCLUDE (${VTK_BINARY_DIR}/Wrapping/Tcl/LocalUserOptions.cmake OPTIONAL)
......
......@@ -5,9 +5,10 @@ setup.py for installing the VTK-Python bindings using distutils.
Created by Prabhu Ramachandran, June 2002.
Updated for install with configuration types by Brad King, August 2005.
"""
import glob
import sys
import string
import os
......@@ -27,30 +28,55 @@ has_setup_tools = 0
#from setuptools import setup
#has_setup_tools = 1
version = "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}"
build_lib_dir = "${LIBRARY_OUTPUT_PATH}"
build_bin_dir = "${EXECUTABLE_OUTPUT_PATH}"
# The build type ('Release', 'Debug' etc.). This may also be
# overridden on the command line by something like
# 'BUILD_TYPE=Release'. For example::
# VTK build configuration settings.
vtk_version = "@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.@VTK_BUILD_VERSION@"
vtk_lib_dir = "@LIBRARY_OUTPUT_PATH@"
vtk_bin_dir = "@EXECUTABLE_OUTPUT_PATH@"
vtk_use_rendering = @VTK_PYTHON_USE_RENDERING@
vtk_use_parallel = @VTK_PYTHON_USE_PARALLEL@
vtk_use_mpi = @VTK_PYTHON_USE_MPI@
vtk_has_configuration_types = @VTK_PYTHON_HAS_CONFIG_TYPES@
# The build type ('Release', 'Debug' etc.). If vtk_has_configuration_types
# is true this must be set. It may be set on the command line by something
# like 'BUILD_TYPE=Release'. For example::
# python setup.py install --prefix=D:\\Python23 BUILD_TYPE=Release
build_type = "${CMAKE_BUILD_TYPE}"
vtk_build_type = @VTK_PYTHON_BUILD_TYPE@
# Construct the list of kit names to be installed.
vtk_kit_names = ['Common', 'Filtering', 'IO', 'Graphics',
'GenericFiltering', 'Imaging']
if vtk_use_rendering:
vtk_kit_names.extend(['Rendering', 'VolumeRendering', 'Hybrid', 'Widgets'])
if vtk_use_parallel:
vtk_kit_names.extend(['Parallel'])
# Construct the list of executable names to be installed.
vtk_exe_names = ['vtkpython']
if vtk_use_parallel and vtk_use_mpi:
vtk_exe_names.extend(['pvtkpython'])
def get_libs():
"""Returns a list of libraries to be installed. """
libs = []
# Select platform-specific components of the module file names.
if os.name == 'posix':
pth = os.path.join(build_lib_dir,
'libvtk*Python' + get_config_var('SO'))
libs = glob.glob(os.path.abspath(pth))
dir = vtk_lib_dir
prefix = 'libvtk'
suffix = 'Python' + get_config_var('SO')
else:
d = os.path.join(build_bin_dir.replace('/', '\\'), build_type)
libs = glob.glob(os.path.join(d, 'vtk*Python.dll'))
dir = vtk_bin_dir.replace('/', '\\')
prefix = 'vtk'
suffix = 'Python.dll'
# If this build has configuration types append the selected configuration.
if vtk_has_configuration_types:
dir = os.path.join(dir, vtk_build_type)
# Enumerate ths list of module files.
for kit in vtk_kit_names:
libs.append(os.path.abspath(os.path.join(dir, prefix+kit+suffix)))
return libs
......@@ -59,19 +85,23 @@ def get_scripts():
"""Returns the appropriate vtkpython executable and pvtkpython
that is to be installed."""
scripts = []
# Select platform-specific components of the executable file names.
if os.name == 'posix':
for i in ('vtkpython', 'pvtkpython'):
f = os.path.join(build_bin_dir, i)
if os.path.exists(f):
scripts.append(f)
dir = vtk_lib_dir
suffix = ''
else:
# Under win32 the binary is inside a sub-directory.
win32_bin_dir = os.path.normpath(os.path.join(build_bin_dir,
build_type))
for i in ('vtkpython.exe', 'pvtkpython.exe'):
f = os.path.join(win32_bin_dir, i)
if os.path.exists(f):
scripts.append(f)
dir = vtk_bin_dir.replace('/', '\\')
suffix = '.exe'
# If this build has configuration types append the selected configuration.
if vtk_has_configuration_types:
dir = os.path.join(dir, vtk_build_type)
# Enumerate ths list of executable files.
for exe in vtk_exe_names:
scripts.append(os.path.abspath(os.path.join(dir, exe+suffix)))
return scripts
......@@ -88,10 +118,15 @@ if __name__ == '__main__':
# Get the optional build type argument.
for x in sys.argv[:]:
if 'BUILD_TYPE' in x:
build_type = string.strip(string.split(x, '=')[1])
vtk_build_type = string.strip(string.split(x, '=')[1])
sys.argv.remove(x)
break
# Make sure a build type was specified if it is required.
if vtk_has_configuration_types:
if not vtk_build_type:
raise "ERROR: Must specify BUILD_TYPE=<config-name> on command line."
def mk_dict(**kw):
# Unnecessary in recent Pythons but handy for earlier
# versions.
......@@ -99,7 +134,7 @@ if __name__ == '__main__':
# The options for setup.
opts = mk_dict(name = "VTK",
version = version,
version = vtk_version,
description = "The Visualization Toolkit",
maintainer = "VTK Developers",
maintainer_email = "vtk-developers@vtk.org",
......
Supports Markdown
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