File OpenColorIO-setuptools.patch of Package OpenColorIO

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,8 @@ option(OCIO_PYGLUE_LIB_PREFIX "If ON, pr
 if(UNIX AND NOT APPLE)
     option(USE_EXTERNAL_YAML "Use system installed yaml-cpp library." OFF)
     option(USE_EXTERNAL_TINYXML "Use system installed tinyxml library." OFF)
-    option(USE_EXTERNAL_LCMS "Use system install lcms2 library." OFF)
+    option(USE_EXTERNAL_LCMS "Use system installed lcms2 library." OFF)
+    option(USE_EXTERNAL_SETUPTOOLS "Use system installed python setuptools." OFF)
 endif()
 
 # This does not include the SOVERSION override, on purpose, so that the
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -19,18 +19,22 @@ else()
     set(PYT_EXTDIST_BINPATH ${EXTDIST_BINPATH})
 endif()
 
-# setuptools
-# https://pypi.python.org/pypi/setuptools
-set(SETUPTOOLS_VERSION 1.1.6)
-
-ExternalProject_Add(setuptools
-    URL ${CMAKE_SOURCE_DIR}/ext/setuptools-${SETUPTOOLS_VERSION}.tar.gz
-    BUILD_IN_SOURCE 1
-    CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
-    BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
-    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT}
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/setuptools-prefix/src/setuptools
-)
+if(USE_EXTERNAL_SETUPTOOLS)
+    add_custom_target(setuptools /usr/bin/true)
+else()
+    # setuptools
+    # https://pypi.python.org/pypi/setuptools
+    set(SETUPTOOLS_VERSION 1.1.6)
+   
+    ExternalProject_Add(setuptools
+        URL ${CMAKE_SOURCE_DIR}/ext/setuptools-${SETUPTOOLS_VERSION}.tar.gz
+        BUILD_IN_SOURCE 1
+        CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
+        BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
+        INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-lib=${EXTDIST_PYTHONPATH}
+        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/setuptools-prefix/src/setuptools
+    )
+endif()
 
 # docutils
 # https://pypi.python.org/pypi/docutils
@@ -41,7 +45,7 @@ ExternalProject_Add(docutils
     BUILD_IN_SOURCE 1
     CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
     BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
-    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT}
+    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-lib=${EXTDIST_PYTHONPATH}
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docutils-prefix/src/docutils
 )
 
@@ -54,7 +58,7 @@ ExternalProject_Add(Jinja2
     BUILD_IN_SOURCE 1
     CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
     BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
-    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT}
+    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-lib=${EXTDIST_PYTHONPATH}
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Jinja2-prefix/src/Jinja2
 )
 
@@ -67,7 +71,7 @@ ExternalProject_Add(Pygments
     BUILD_IN_SOURCE 1
     CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
     BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
-    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT}
+    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-lib=${EXTDIST_PYTHONPATH}
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Pygments-prefix/src/Pygments
 )
 
@@ -81,7 +85,7 @@ ExternalProject_Add(Sphinx
     BUILD_IN_SOURCE 1
     CONFIGURE_COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTDIST_PYTHONPATH}
     BUILD_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py build
-    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-scripts=${PYT_EXTDIST_BINPATH}
+    INSTALL_COMMAND ${PYT_PRE_CMD} ${PYTHON} setup.py install --prefix=${PYT_LIB_OUTPUT} --install-scripts=${PYT_EXTDIST_BINPATH} --install-lib=${EXTDIST_PYTHONPATH}
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Sphinx-prefix/src/Sphinx
 )