refactor the way python is used in dune
My extension of Dominic's work on this:
Changes in this MR
Case 1: not running dunecontrol
in a python venv:
the internal python venv is setup. If DUNE_ENABLE_PYTHONBINDINGS=ON
is set the dune python packages are installed there (editable) during the configure phase. The python tests in the build-dir work automatically with the python packages in the build specific dune-env
.
At the moment the only way to turn off the internal venv is to set CMAKE_DISABLE_FIND_PACKAGE_Python3=TRUE
which then disables all python in the builddir.
Case 2: running dunecontrol
in a python venv:
More or less the same as before but the external venv is used instead of a newly created internal one.
Python bindings
- As pointed out above the Python bindings are now automatically installed editable into either the newly created internal env or into an active external env. So no additional call to
make install_python
is needed. Executing that command now leads to a non-editable installation into the venv that was active during configure our into the user/system site-packages. - metadata is now generated which is used when building
dune-py
. At the moment this is used to find available dune module sources and to set some cmake flags
Changes to existing bindings for a package dune-foo
- An important change is that the namespace package now follows PEP 420. That means there should be no file
python/dune/__init__.py
anymore. - A standard
setup.py.in
is provided indune-common
so probablysetup.py.in
can be removed. If you have a customsetup.py.in
you need to usepackages=find_namespace_packages(include=['dune.*'])
instead ofnamespace_packages=['dune']
and thesetup
command insetup.py.in
should also include the parameterinclude_package_data=True
Finally, the line insetup.py
definingpkg
now need to bepkg = '${RequiredPythonModules}'.replace(';',' ').split(' ')
- Remove the
configure_file
line frompython/CMakeLists.txt
since this is done in the python install cmake module - The cmake function
dune_python_install_package
has been extended to set up this metadata. The call should be moved from the top levelCMakeLists.txt
file to the location of thesetup.py.in
file (i.e.python
in the core modules). A typical call would be
dune_python_install_package(
PATH "." # relative path containing the package
DEPENDS _foo # if applicable: generated modules (libs)
CMAKE_METADATA_FILE dune/foo/metadata.cmake # metadata file to generate
CMAKE_METADATA_FLAGS CMAKE_PACKAGE_FLAGS # if applicable: some cmake flags to store
)
The final line could for example be CMAKE_METADATA_FLAGS SUPER_LU_ROOT
(in dune-common
that line contains for example CMAKE_METADATA_FLAGS CMAKE_BUILD_TYPE CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS
.
- if a Python module is to be added to the package, the current version of the
CMakeLists.txt
files included something likeinstall(TARGETS _grid LIBRARY DESTINATION python/dune/grid)
(indune-grid
). This should be replaced by
if(SKBUILD)
install(TARGETS _grid LIBRARY DESTINATION python/dune/grid)
endif()
- the
.gitlab.yml
files can be simplified for jobs testing the python bindings
All changes have been done in companion MRs in all core modules and a simple diff there with master shows the required changes.
See also
- dune-geometry!166 (merged)
- dune-grid!492 (merged)
- dune-istl!432 (merged)
- dune-localfunctions!192 (merged)
- extensions/dune-alugrid!113 (merged)
- staging/dune-functions!296 (merged)
- extensions/dune-vtk!31 (merged)
- samuel.burbulla/dune-mmesh!13 (merged)
- dune-fem/dune-fem!425 (merged)
- dune-fem/dune-fem-dg!32 (merged)
- dune-fem/dune-vem!9 (merged)
- infrastructure/dune-nightly-test!5 (merged)
- extensions/dune-polygongrid!3 (merged)
- extensions/dune-spgrid!22 (merged)
Merge request reports
Activity
added 112 commits
-
00afa1bb...b2a3e8ad - 79 commits from branch
master
- a611d77b - Add a .noconfigure tagfile to prevent dune-py from reconfiguration.
- 9e45a6e3 - Add __main__.py to define commands.
- 3fdcef77 - remove upgrade again from pip command
- d4437655 - but --upgrade back in
- 578077a0 - use both DUNE_CMAKE_FLAGS and CMAKE_FLAGS in this order
- 33240214 - [testing]
- 0f8a0ca4 - [testing]
- d1b05491 - remove some debug output
- cc426c8c - WIP
- a6637d85 - Add comment about building in virtualenv
- e177c459 - Always use the internal virtualenv in testing
- 7017c2c4 - Add a DEPENDS option to dune_python_install_package
- ec64943b - Export metadata from CMake in dune_python_install_package
- 03833792 - Build dune-py from a Jinja2 template
- cdb32785 - Move dune_python_install_package to python subdirectory
- aaf3e542 - Fixup - correct path
- cd4dabbf - Deprecate DUNE_PYTHON_INSTALL_EDITABLE user interface
- 7a5435d7 - Implement some more deprecations
- aaa79680 - Remove the INTERPRETER argument from dune_python_add_test
- 34e441b6 - Add installation rule for new CMake module file
- c20dfb6f - Write a different metadata file for global installation
- 08a98244 - Slightly refactor data processing and fix the common-install use case
- 61e5db53 - Fixups
- 6322e394 - Add necessary CMake script file
- 067f8cd2 - More fixups
- 20a207da - Install CMake scipt
- 4fd23b3a - Temporarily disable the dune configure command
- 6046e282 - all dune modules are searched at the beginning now possibly before dune-py has
- dbd24046 - correctly use the tagfile '.noconfigure' to make sure dune-py is rebuild
- 792984b4 - use *.template for dune-py template files which should be copied without
- cd284530 - add cmake install command for the cmake_metadata files and the files in the
- c5942ec2 - check for matplotlib in dune.plotting
- 64bcd96e - Partial fix for export of build dirs for all deps modules to metadat file.
Toggle commit list-
00afa1bb...b2a3e8ad - 79 commits from branch
added 1 commit
- 84c38be1 - Add a 'flag' argument to the 'dune_python_install_package' command which...
added 1 commit
- 07a09318 - [bugfix][PythonVenv] Set DUNE_PYTHON_pip_FOUND if pip was found in venv
added 1 commit
- e9113e4b - only require mpi4py for the dune python package if cmake could find mpi
added 1 commit
- 3d5fb720 - correctly throw exception if dune-py not available in assertHave
added 1 commit
- 08a310ac - as above - testing simplification of cmake flags
added 1 commit
- 5fd48ce0 - add a clang toolchain to test python bindings
added 1 commit
- de1cbf6c - enable embed test by providing the run-in-dune-env as COMMAND option to test
added 1 commit
- 420e74d8 - improve locking mechanism when generating dune-py
added 1 commit
- 68d40cfe - use clang 10-20 for python test since some other parallel tests fail with the clang 10-17 toolchain
mentioned in merge request dune-geometry!166 (merged)
mentioned in merge request dune-grid!492 (merged)
mentioned in merge request dune-istl!432 (merged)
mentioned in merge request extensions/dune-alugrid!113 (merged)
mentioned in merge request dune-fem/dune-fem!425 (merged)
mentioned in merge request dune-fem/dune-fem-dg!32 (merged)
added 1 commit
- 446c0cb7 - [testing] try to fix issue in dune-grid by not requiring mpi4py
mentioned in merge request dune-localfunctions!192 (merged)
added 4 commits
- 6a88d133 - fix an issue with a double installation of the dune module in the case
- efdbdc2b - add a env variable that should lead to a timeout restriction when looking for packages online
- 2b9141a5 - minor improvement to plotting
- 0b81dead - pep 42: use implicit namespace packages which make it possible to combine...
Toggle commit listmentioned in merge request staging/dune-functions!294 (merged)
- Resolved by Andreas Dedner
MR description case 2: I guess 'not' has to be dropped?
added 1 commit
- caabc89e - add a stopgap solution unti ci repo up and running again
added 1 commit
- 4061e06b - we need pip>=21 so that 'make', 'make install_python', 'make' does not