From a81f3c95d7d4b6ec94ccc3ab799f8c7ae7c2e00c Mon Sep 17 00:00:00 2001 From: bruneton Date: Tue, 9 Jul 2013 08:20:43 +0000 Subject: [PATCH] CMake: Adding DOCUTILS_ROOT_DIR and SETUPTOOLS_ROOT_DIR to the PYTHONPATH when invoking the sphinx-build command. --- doc/docutils/CMakeLists.txt | 22 ++++++++++++++----- salome_adm/cmake_files/FindSalomeSphinx.cmake | 18 ++++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/doc/docutils/CMakeLists.txt b/doc/docutils/CMakeLists.txt index 514986152..11bae40af 100755 --- a/doc/docutils/CMakeLists.txt +++ b/doc/docutils/CMakeLists.txt @@ -17,6 +17,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +# This file mainly prepares the environment in which sphinx should run: +# this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ... + +# Prepare Sphinx options SET(SPHINXOPTS ) SET(SOURCEDIR @@ -36,8 +40,13 @@ SET(ALLSPHINXOPTS SALOME_CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" "${CMAKE_CURRENT_BINARY_DIR}/conf.py") +# Write the shell file preparing the env for the Sphinx run: +# This uses the paths to SPHINX, DOCUTILS and SETUPTOOLS: +# Their root dir were found when looking for Sphinx (FindSalomeSphinx.cmake): + +SET(_pydir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) IF(WINDOWS) - STRING(REPLACE "/" "\\" SCR "@SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\lib\\python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}\\site-packages\\salome\;%PYTHONPATH% + STRING(REPLACE "/" "\\" SCR "@SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\lib\\${_pydir}\\site-packages\\salome\;%PYTHONPATH% @SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\bin\\salome\;%PYTHONPATH% @SET PATH=${CMAKE_INSTALL_PREFIX}\\lib\\salome\;%PATH% @SET PYTHONPATH=${OMNIORB_ROOT_DIR}\\lib\\x86_win32\;%PYTHONPATH% @@ -47,15 +56,18 @@ IF(WINDOWS) SET(EXT "bat") SET(CALL_STR "call") ELSE(WINDOWS) - SET(SCR " export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/salome:\${PYTHONPATH} + SET(SCR " export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib/${_pydir}/site-packages/salome:\${PYTHONPATH} export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/bin/salome:\${PYTHONPATH} export LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib/salome:\${LD_LIBRARY_PATH} export PYTHONPATH=${OMNIORB_ROOT_DIR}/lib:\${PYTHONPATH} - export PYTHONPATH=${OMNIORB_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages:\${PYTHONPATH} + export PYTHONPATH=${OMNIORB_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH} export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib:\${PYTHONPATH} - export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages:\${PYTHONPATH} + export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH} export LD_LIBRARY_PATH=${OMNIORB_ROOT_DIR}/lib:\${LD_LIBRARY_PATH} - ") + export PYTHONPATH=${SETUPTOOLS_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH} + export PYTHONPATH=${DOCUTILS_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH} + export PYTHONPATH=${SPHINX_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}" + ) SET(EXT "sh") SET(CALL_STR ".") ENDIF(WINDOWS) diff --git a/salome_adm/cmake_files/FindSalomeSphinx.cmake b/salome_adm/cmake_files/FindSalomeSphinx.cmake index f769a43cb..5775e69ed 100644 --- a/salome_adm/cmake_files/FindSalomeSphinx.cmake +++ b/salome_adm/cmake_files/FindSalomeSphinx.cmake @@ -23,16 +23,22 @@ # # The caller of this macro might set SPHINX_PYTHONPATH to provide a PYTHONPATH with # which the sphinx command should be ran. +# Note the environment is also overriden in +# doc/docutils/CMakeLists.txt +# with the creation of a dedicated launcher script. # SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Sphinx SPHINX_EXECUTABLE 2) +# Also retrieve paths to DOCUTILS and SETUPTOOLS: +SET(SETUPTOOLS_ROOT_DIR "$ENV{SETUPTOOLS_ROOT_DIR}" CACHE PATH "Path to the Setuptools installation") +SET(DOCUTILS_ROOT_DIR "$ENV{DOCUTILS_ROOT_DIR}" CACHE PATH "Path to the Setuptools installation") + # Ensure the command is run with the given PYTHONPATH -IF(WIN32 AND NOT CYGWIN) - MESSAGE(WARNING "Sphinx windows command needs a proper PYTHONPATH to run.") -ELSE() - SET(SPHINX_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$ENV{PYTHONPATH}" ${SPHINX_EXECUTABLE}) -ENDIF() +#IF(WIN32 AND NOT CYGWIN) +# MESSAGE(WARNING "Sphinx windows command needs a proper PYTHONPATH to run.") +#ELSE() +# SET(SPHINX_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$ENV{PYTHONPATH}" ${SPHINX_EXECUTABLE}) +#ENDIF() MARK_AS_ADVANCED(SPHINX_EXECUTABLE) -#message("SPHINX_EXECUTABLE : ${SPHINX_EXECUTABLE}") -- 2.39.2