[vtkusers] Building VTK with Python 2.6 on Windows 7
Thomas Templier
templier at neuro.mpg.de
Wed Jun 8 13:37:05 EDT 2011
I just changed the PYTHON_LIBRARY and it worked. Instead of giving the filepath to python26.lib, I gave the path to libs or Lib.
I did not have to change the PYTHON_INCLUD_DIR and PYTHON_EXECUTABLE.
Thank you
Best Regards
Thomas
From: David Partyka [mailto:david.partyka at kitware.com]
Sent: Wednesday, June 08, 2011 1:45 PM
To: Thomas Templier
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Building VTK with Python 2.6 on Windows 7
The first line of the error message is the key.
Set PYTHON_LIBRARY in the cmake interface to the location of your Python library. For example on my system it is set to:
PYTHON_LIBRARY C:/Kitware/ParaView 3.10/build-x32/python-build/PCbuild/python27.lib
You will likely also need to set PYTHON_INCLUD_DIR and PYTHON_EXECUTABLE in a similar fashion.
On Wed, Jun 8, 2011 at 7:28 AM, Thomas Templier <templier at neuro.mpg.de<mailto:templier at neuro.mpg.de>> wrote:
Cmake 2.8.4
VTK 5.6.1
Compiler : Microsoft Visual C++ 2010 Express
Dear list,
I'm struggling with the installation of VTK with python. In Cmake, I activate VTK_WRAP_PYTHON and BUILD_SHARED_LIBS. It gives me the following (see below):
Then I tried all possible combinations to set the pathways for include, and for the libraries (with PATH, DIR or even DIRS) (should I set /Lib or /libs ?) , then I have the same log as before.
I've googled it, and found that some years ago, Cmake had a problem with finding Pyhon libraries. But it seems to have been fixed a long time ago also. Here is my FindPythonLibs file (below):
I don't understand why it does not work.
Has anybody an idea to help me ?
Thank you
Best Regards
Thomas
Could NOT find PythonLibs (missing: PYTHON_LIBRARIES)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PYTHON_LIBRARY (ADVANCED)
linked by target "vtkWrapPython" in directory C:/VTK/vtk-5.4.2/Wrapping
linked by target "vtkCommonPython" in directory C:/VTK/vtk-5.4.2/Common
linked by target "vtkCommonPythonD" in directory C:/VTK/vtk-5.4.2/Common
linked by target "vtkFilteringPython" in directory C:/VTK/vtk-5.4.2/Filtering
linked by target "vtkFilteringPythonD" in directory C:/VTK/vtk-5.4.2/Filtering
linked by target "vtkImagingPython" in directory C:/VTK/vtk-5.4.2/Imaging
linked by target "vtkImagingPythonD" in directory C:/VTK/vtk-5.4.2/Imaging
linked by target "vtkGraphicsPython" in directory C:/VTK/vtk-5.4.2/Graphics
linked by target "vtkGraphicsPythonD" in directory C:/VTK/vtk-5.4.2/Graphics
linked by target "vtkGenericFilteringPython" in directory C:/VTK/vtk-5.4.2/GenericFiltering
linked by target "vtkGenericFilteringPythonD" in directory C:/VTK/vtk-5.4.2/GenericFiltering
linked by target "vtkIOPython" in directory C:/VTK/vtk-5.4.2/IO
linked by target "vtkIOPythonD" in directory C:/VTK/vtk-5.4.2/IO
linked by target "vtkRenderingPython" in directory C:/VTK/vtk-5.4.2/Rendering
linked by target "vtkRenderingPythonD" in directory C:/VTK/vtk-5.4.2/Rendering
linked by target "vtkVolumeRenderingPython" in directory C:/VTK/vtk-5.4.2/VolumeRendering
linked by target "vtkVolumeRenderingPythonD" in directory C:/VTK/vtk-5.4.2/VolumeRendering
linked by target "vtkHybridPython" in directory C:/VTK/vtk-5.4.2/Hybrid
linked by target "vtkHybridPythonD" in directory C:/VTK/vtk-5.4.2/Hybrid
linked by target "vtkWidgetsPython" in directory C:/VTK/vtk-5.4.2/Widgets
linked by target "vtkWidgetsPythonD" in directory C:/VTK/vtk-5.4.2/Widgets
linked by target "vtkInfovisPython" in directory C:/VTK/vtk-5.4.2/Infovis
linked by target "vtkInfovisPythonD" in directory C:/VTK/vtk-5.4.2/Infovis
linked by target "vtkGeovisPython" in directory C:/VTK/vtk-5.4.2/Geovis
linked by target "vtkGeovisPythonD" in directory C:/VTK/vtk-5.4.2/Geovis
linked by target "vtkViewsPython" in directory C:/VTK/vtk-5.4.2/Views
linked by target "vtkViewsPythonD" in directory C:/VTK/vtk-5.4.2/Views
linked by target "vtkpython" in directory C:/VTK/vtk-5.4.2/Wrapping/Python
Configuring incomplete, errors occurred!
*************
*************
*************
FindPythonLibs
# - Find python libraries
# This module finds if Python is installed and determines where the
# include files and libraries are. It also determines what the name of
# the library is. This code sets the following variables:
#
# PYTHONLIBS_FOUND - have the Python libs been found
# PYTHON_LIBRARIES - path to the python library
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
# PYTHON_DEBUG_LIBRARIES - path to the debug library
# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
INCLUDE(CMakeFindFrameworks)
# Search for the python framework on Apple.
CMAKE_FIND_FRAMEWORKS(Python)
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
set(_Python_VERSIONS
${Python_ADDITIONAL_VERSIONS}
2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
FOREACH(_CURRENT_VERSION ${_Python_VERSIONS})
STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
IF(WIN32)
FIND_LIBRARY(PYTHON_DEBUG_LIBRARY
NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs )
ENDIF(WIN32)
FIND_LIBRARY(PYTHON_LIBRARY
NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
# Avoid finding the .dll in the PATH. We want the .lib.
NO_SYSTEM_ENVIRONMENT_PATH
)
# Look for the static library in the Python config directory
FIND_LIBRARY(PYTHON_LIBRARY
NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
# Avoid finding the .dll in the PATH. We want the .lib.
NO_SYSTEM_ENVIRONMENT_PATH
# This is where the static library is usually located
PATH_SUFFIXES python${_CURRENT_VERSION}/config
)
# For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if
# PYTHON_INCLUDE_DIR is not set.
IF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
SET(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
"Path to where Python.h is found" FORCE)
ENDIF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
SET(PYTHON_FRAMEWORK_INCLUDES)
IF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
FOREACH(dir ${Python_FRAMEWORKS})
SET(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION})
ENDFOREACH(dir)
ENDIF(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
FIND_PATH(PYTHON_INCLUDE_DIR
NAMES Python.h
PATHS
${PYTHON_FRAMEWORK_INCLUDES}
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
PATH_SUFFIXES
python${_CURRENT_VERSION}
)
# For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal.
SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL
"Path to where Python.h is found (deprecated)")
ENDFOREACH(_CURRENT_VERSION)
MARK_AS_ADVANCED(
PYTHON_DEBUG_LIBRARY
PYTHON_LIBRARY
PYTHON_INCLUDE_DIR
)
# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
# cache entries because they are meant to specify the location of a single
# library. We now set the variables listed by the documentation for this
# module.
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
# in your sources to initialize the static python modules
FUNCTION(PYTHON_ADD_MODULE _NAME )
GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED
"Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
# Mark these options as advanced
MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME}
PYTHON_MODULE_${_NAME}_BUILD_SHARED)
IF(PYTHON_ENABLE_MODULE_${_NAME})
IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
SET(PY_MODULE_TYPE MODULE)
ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
SET(PY_MODULE_TYPE STATIC)
SET_PROPERTY(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
SET_PROPERTY(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
# TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES})
IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
ENDIF(PYTHON_ENABLE_MODULE_${_NAME})
ENDFUNCTION(PYTHON_ADD_MODULE)
FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename)
GET_PROPERTY(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST)
GET_FILENAME_COMPONENT(_name "${_filename}" NAME)
STRING(REPLACE "." "_" _name "${_name}")
STRING(TOUPPER ${_name} _nameUpper)
SET(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
SET(_filenameTmp "${_filename}.in")
FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
FILE(APPEND ${_filenameTmp}
"#ifndef ${_nameUpper}
#define ${_nameUpper}
#include <Python.h>
#ifdef __cplusplus
extern \"C\" {
#endif /* __cplusplus */
")
FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp}
"#ifdef __cplusplus
}
#endif /* __cplusplus */
")
FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} "}\n\n")
FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
# with CONFIGURE_FILE() cmake complains that you may not use a file created using FILE(WRITE) as input file for CONFIGURE_FILE()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
ENDFUNCTION(PYTHON_WRITE_MODULES_HEADER)
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110608/9109ff76/attachment.htm>
More information about the vtkusers
mailing list