dune-python migration
As decided on the Dune developer meeting, I will migrate the python build system infrastructure currently located in dune-python to dune-common. I will try to split the migration into 3 parts:
- !218 (merged) is kinda unrelated, but used in the project (for sake of simplicity, this MR builds upon that branch)
- This MR will contain all the stuff that I consider useful for all python related projects, such as
- finding interpreter and libraries
- checking availability of python packages
- defining installation rules for python packages
- run python test commands during
ctest
- An upcoming merge request (!220 (merged)) will implement everything that relates to the configure-time envsetup currently used by projects that need to run python from cmake.
To grasp the changes of this MR:
-
DunePythonCommonMacros
is the entry-level module, where all the logic that is executed during configuration of dune-common is located - All the cmake modules prefixed with
DunePython
contain code that is intended to be used by users. It is documented with Sphinx.
Merge request reports
Activity
- Resolved by Dominic Kempf
added 1 commit
- 6c0b497f - [bugfix] Exit the version checking script if a version has been found
- cmake/modules/DunePythonCommonMacros.cmake 0 → 100644
26 include(DunePythonFindPackage) 27 include(DunePythonInstallPackage) 28 include(DunePythonRequireVersion) 29 30 # Find the Python Interpreter 31 set(_VERSION_STRING "") 32 if(DUNE_PYTHON_FORCE_PYTHON2 AND DUNE_PYTHON_FORCE_PYTHON3) 33 message(FATAL_ERROR "Cannot enforce both python2 *and* python3") 34 endif() 35 if(DUNE_PYTHON_FORCE_PYTHON2) 36 set(_VERSION_STRING "2") 37 endif() 38 if(DUNE_PYTHON_FORCE_PYTHON3) 39 set(_VERSION_STRING "3") 40 endif() 41 find_package(PythonInterp ${_VERSION_STRING}) There is an inherent chicken-egg problem with the buildsystem setting
Python_ADDITIONAL_VERSIONS
: The check is triggered from dune-common, but other modules can pose constraints on the interpreter version. My current approach is: Find the interpreter and nag afterwards, if it was not sufficiently new. This of course relies on distributions to define reasonably new default interpreters. Then again, in the case of the system interpreter being in a virtualenv, it is the correct procedure anyway, as the user needs to actively choose the interpreter when setting up the env (so the buildsystem does not even have a choice).@martin.nolte Oh, I just found out I completely misunderstood the purpose of
Python_ADDITIONAL_VERSIONS
. I always interpreted its semantics totally different... So it turns out it IS needed to have old cmake find new pythons (Why, only the cmake god knows (if existent)). I am very sorry.
While working on it, I decided to omit the functionality to install standalone python scripts , as it is so hard to correctly determine the location to move them to. If somebody direly needs scripts, I recommend adding a dummy setup.py and have it be installed as a python package to have pip figure out the correct paths. Shout, if you disagree.
So if I've already have them in setup.py, I'm good? https://github.com/dune-community/dune-xt-common/blob/master/python/setup.py
In case that's true, than I'm not shouting
@rene.milk Exactly, that is the way I am promoting as clean solution.
added 1 commit
- 984645b2 - [bugfix] 'Correctly' pass list arguments to CMake script
added 1 commit
- f707196e - [doc] Document how to invoke the python interpreter in test commands
added 1 commit
- 26ded7f5 - Check that install location 'user' is not used inside virtual environments
The branch is now in a state that includes all the features I was envisioning for it. I have redesigned many interfaces (in comparison to dune-python), so it requires thorough testing although I am using similar concepts for quite a while already. Any feedback is welcome. I will now go on and implement the MR on top that does the virtualenv stuff, as I need that to do meaningful testing with my existing projects.
added 1 commit
- 0f58c7ca - Simplify some logic about whether a package was found
added 1 commit
- c804884a - Have dune_python_find_package take an alternative interpreter