Skip to content

Commit

Permalink
[Exp PyROOT] Eggs created in a less pythonic way if requisites not sa…
Browse files Browse the repository at this point in the history
…tisfied

Python eggs for PyROOT and Cppyy cannot be created in a complete and
pythonic way if setuptools is not installed and version is > 3.3. The
absence of this conditions actually also make the entire build fail.
If the requisites are not satisfied, eggs are created in a simpler way (with less information).
  • Loading branch information
maxgalli committed Nov 22, 2019
1 parent 95190cc commit 224c948
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bindings/pyroot_experimental/cppyy/cppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,13 @@ foreach(py_source ${py_sources})
endforeach()

# create egg with cppyy info
add_custom_target(cppyy_egg ALL COMMAND ${PYTHON_EXECUTABLE} setup.py install_egg_info -d ${py_localruntimedir}/cppyy WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(TARGET cppyy_egg POST_BUILD COMMAND bash -c "rm -rf python/*.egg-info" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(COMMAND bash -c "${PYTHON_EXECUTABLE} -c 'import setuptools; import distutils'; echo $?" OUTPUT_VARIABLE packages_installed)
execute_process(COMMAND bash -c "${PYTHON_EXECUTABLE} -c 'import setuptools as s; l = s.__version__.split(\".\"); l = l[0:2]; print(\".\".join(l))'" OUTPUT_VARIABLE setuptools_version)
if(packages_installed EQUAL 0 AND setuptools_version GREATER_EQUAL 3.3)
add_custom_target(cppyy_egg ALL COMMAND ${PYTHON_EXECUTABLE} setup.py install_egg_info -d ${py_localruntimedir}/cppyy WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(TARGET cppyy_egg POST_BUILD COMMAND bash -c "rm -rf python/*.egg-info" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
else()
# create cppyy egg in a dummy way
set(cppyy_egg "${CMAKE_CURRENT_BINARY_DIR}/cppyy.egg")
execute_process(COMMAND bash -c "touch ${cppyy_egg}; cat ${CMAKE_CURRENT_SOURCE_DIR}/python/cppyy/_version.py > ${cppyy_egg}")
endif()

0 comments on commit 224c948

Please sign in to comment.