Skip to content
Snippets Groups Projects
Commit 6a95fe94 authored by Andreas Dedner's avatar Andreas Dedner
Browse files

only add dune modules that have python bindings as requirements in setup.py.in

This requires an addition module_HASPYTHON flag in module-config.cmake

add a MODULE_HASPYTHON variable
parent b5248983
Branches
Tags
1 merge request!960refactor the way python is used in dune
......@@ -777,6 +777,7 @@ set(${ProjectName}_DEPENDS \"@${ProjectName}_DEPENDS@\")
set(${ProjectName}_SUGGESTS \"@${ProjectName}_SUGGESTS@\")
set(${ProjectName}_MODULE_PATH \"@PACKAGE_DUNE_INSTALL_MODULEDIR@\")
set(${ProjectName}_LIBRARIES \"@DUNE_MODULE_LIBRARIES@\")
set(${ProjectName}_HASPYTHON @DUNE_MODULE_HASPYTHON@)
# Lines that are set by the CMake build system via the variable DUNE_CUSTOM_PKG_CONFIG_SECTION
${DUNE_CUSTOM_PKG_CONFIG_SECTION}
......@@ -786,6 +787,7 @@ if(${ProjectName}_LIBRARIES)
get_filename_component(_dir \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)
include(\"\${_dir}/${ProjectName}-targets.cmake\")
endif()
endif()")
set(CONFIG_SOURCE_FILE ${PROJECT_BINARY_DIR}/CMakeFiles/${ProjectName}-config.cmake.in)
else()
......@@ -809,6 +811,11 @@ endif()")
# file section of dune-grid.
set(DUNE_MODULE_SRC_DOCDIR "${PROJECT_SOURCE_DIR}/doc")
set(MODULE_INSTALLED ON)
if(EXISTS ${PROJECT_SOURCE_DIR}/python)
set(DUNE_MODULE_HASPYTHON 1)
else()
set(DUNE_MODULE_HASPYTHON 0)
endif()
configure_package_config_file(${CONFIG_SOURCE_FILE}
${PROJECT_BINARY_DIR}/cmake/pkg/${ProjectName}-config.cmake
......@@ -833,6 +840,7 @@ macro(set_and_check _var _file)
endif()
endmacro()")
set(MODULE_INSTALLED OFF)
configure_file(
${CONFIG_SOURCE_FILE}
${PROJECT_BINARY_DIR}/${ProjectName}-config.cmake @ONLY)
......
......@@ -65,6 +65,14 @@ function(dune_python_install_package)
endif()
# Configure setup.py.in if present
set(RequiredPythonModules "${ProjectPythonRequires}")
foreach(mod ${ALL_DEPENDENCIES})
if(${${mod}_HASPYTHON}) # module found and has python bindings
string(APPEND RequiredPythonModules " ${mod}")
endif()
endforeach()
set(PYINST_FULLPATH ${CMAKE_CURRENT_SOURCE_DIR}/${PYINST_PATH})
if(EXISTS ${PYINST_FULLPATH}/setup.py.in)
configure_file(${PYINST_PATH}/setup.py.in ${PYINST_PATH}/setup.py)
......
......@@ -19,5 +19,6 @@ set_and_check(DOXYSTYLE_FILE "@PACKAGE_DOXYSTYLE_DIR@/Doxystyle")
set_and_check(DOXYGENMACROS_FILE "@PACKAGE_DOXYSTYLE_DIR@/doxygen-macros")
set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@")
set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@")
set(@DUNE_MOD_NAME@_HASPYTHON 1)
set_and_check(@DUNE_MOD_NAME@_MODULE_PATH "@PACKAGE_DUNE_INSTALL_MODULEDIR@")
endif(NOT @DUNE_MOD_NAME@_FOUND)
......@@ -7,7 +7,6 @@ add_subdirectory(dune)
# endif()
configure_file(MANIFEST.in MANIFEST.in)
configure_file(setup.py.in setup.py)
configure_file(pyproject.toml.in pyproject.toml)
dune_python_install_package(
......
......@@ -409,9 +409,9 @@ class MetaDataDict(dict):
result[k] = v
return result
def unique_value_across_modules(self,key, default=""):
values = set(m[key] for m in self.values())
values = set(m[key] for m in self.values() if not m[key] == "")
if len(values) > 1:
raise ValueError(f"Key {key} is expected to be unique across the given metadata")
raise ValueError(f"Key {key} is expected to be unique across the given metadata. Got {values}")
if len(values) == 0:
return default
value, = values
......
from setuptools import setup, find_namespace_packages
pkg = '${ProjectPythonRequires} ${ALL_DEPENDENCIES}'.replace(';',' ').split(' ')
pkg = '${RequiredPythonModules}'.replace(';',' ').split(' ')
setup(name="${ProjectName}",
# only add 'dune' here in dune-common other packages shouldn't add file # directly to 'dune'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment