From f537a5cd4c747794762e58da9a524a6a82fc2e76 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 27 May 2015 15:04:46 +0100 Subject: [PATCH] cmake: make sphinx use a python-staging folder instead of site-packages This means that you no longer need to install UPM in oder to be able to use `make pydoc`. The target pydoc now depends on target doc which with SWIG will cause python modules to be built, making parralel builds work as expected. We wipe the python-staging directory on each make pydoc as it's a custom_target and will rerun at every time anyways, copy is cheap and in case a module gets deleted it avoids the doc still getting built Signed-off-by: Brendan Le Foll --- CMakeLists.txt | 13 +++++++------ doxy/conf.py.in | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8509f7ca..f4f97f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ if (BUILDDOC) string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING}) list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR) list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR) - set (SITE_PACKAGES ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) + set (SITE_PACKAGES ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) # throw a warning if site-packages doesn't exist, might need a more robust way on adding make install dependency and paths if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${SITE_PACKAGES}) @@ -89,18 +89,19 @@ if (BUILDDOC) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY) add_custom_target (pydoc - ${SPHINX_API_EXECUTABLE} -f -o pydoc ${SITE_PACKAGES} + COMMAND rm -r ${CMAKE_BINARY_DIR}/python-staging && mkdir -p ${CMAKE_BINARY_DIR}/python-staging + COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/python-staging \; + COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/python-staging \; + COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/python-staging # todo: use a separate cmake FILE module for string replacement instead - COMMAND sed -i.bak s|site-packages|sensor-drivers|g pydoc/modules.rst COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html COMMAND sed -i.bak s|[[:space:]]module||g html/python/index.html html/python/modules.html - # cleanup .pyc files - COMMAND find ${SITE_PACKAGES} -name *.pyc -exec rm {} \; + DEPENDS doc WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Sphinx" VERBATIM ) - endif() + endif () # check if Yuidoc is installed and add target for API documentation find_package(Yuidoc) if(YUIDOC_FOUND) diff --git a/doxy/conf.py.in b/doxy/conf.py.in index e47c79b2..c9e513d7 100644 --- a/doxy/conf.py.in +++ b/doxy/conf.py.in @@ -20,8 +20,7 @@ import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, "@CMAKE_INSTALL_LIBDIR@/python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@/site-packages/") -sys.path.insert(0, "@CMAKE_INSTALL_LIBDIR@") +sys.path.insert(0, "@CMAKE_CURRENT_BINARY_DIR@/python-staging/") sys.path.insert(0, "@MRAA_LIBDIR@@LIB_SUFFIX@") # -- General configuration ------------------------------------------------